2 * This file is part of the XSL implementation.
4 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
23 #ifndef XSLStyleSheet_h
24 #define XSLStyleSheet_h
28 #include "ProcessingInstruction.h"
29 #include "StyleSheet.h"
32 #include <libxml/parser.h>
33 #include <libxslt/transform.h>
36 #include <wtf/PassRefPtr.h>
42 class XSLStyleSheet : public StyleSheet {
45 static PassRefPtr<XSLStyleSheet> create(XSLImportRule* parentImport, const String& originalURL, const KURL& finalURL)
47 return adoptRef(new XSLStyleSheet(parentImport, originalURL, finalURL));
50 static PassRefPtr<XSLStyleSheet> create(ProcessingInstruction* parentNode, const String& originalURL, const KURL& finalURL)
52 return adoptRef(new XSLStyleSheet(parentNode, originalURL, finalURL, false));
54 static PassRefPtr<XSLStyleSheet> createEmbedded(ProcessingInstruction* parentNode, const KURL& finalURL)
56 return adoptRef(new XSLStyleSheet(parentNode, finalURL.string(), finalURL, true));
59 // Taking an arbitrary node is unsafe, because owner node pointer can become stale.
60 // XSLTProcessor ensures that the stylesheet doesn't outlive its parent, in part by not exposing it to JavaScript.
61 static PassRefPtr<XSLStyleSheet> createForXSLTProcessor(Node* parentNode, const String& originalURL, const KURL& finalURL)
63 return adoptRef(new XSLStyleSheet(parentNode, originalURL, finalURL, false));
66 virtual ~XSLStyleSheet();
68 virtual bool isXSLStyleSheet() const { return true; }
70 virtual String type() const { return "text/xml"; }
72 virtual bool parseString(const String &string, bool strict = true);
74 virtual bool isLoading();
75 virtual void checkLoaded();
77 void loadChildSheets();
78 void loadChildSheet(const String& href);
80 CachedResourceLoader* cachedResourceLoader();
82 Document* ownerDocument();
83 XSLStyleSheet* parentStyleSheet() const { return m_parentStyleSheet; }
84 void setParentStyleSheet(XSLStyleSheet* parent);
87 String sheetString() const { return m_sheetString; }
90 xsltStylesheetPtr compileStyleSheet();
91 xmlDocPtr locateStylesheetSubResource(xmlDocPtr parentDoc, const xmlChar* uri);
94 void clearDocuments();
96 void markAsProcessed();
97 bool processed() const { return m_processed; }
100 XSLStyleSheet(Node* parentNode, const String& originalURL, const KURL& finalURL, bool embedded);
102 XSLStyleSheet(XSLImportRule* parentImport, const String& originalURL, const KURL& finalURL);
105 Document* m_ownerDocument;
110 String m_sheetString;
112 xmlDocPtr m_stylesheetDoc;
113 bool m_stylesheetDocTaken;
116 XSLStyleSheet* m_parentStyleSheet;
119 } // namespace WebCore
121 #endif // ENABLE(XSLT)
123 #endif // XSLStyleSheet_h