1 /* 2 * This file is part of the XSL implementation. 3 * 4 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. 5 * 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. 10 * 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. 15 * 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. 20 * 21 */ 22 23 #ifndef XSLStyleSheet_h 24 #define XSLStyleSheet_h 25 26 #if ENABLE(XSLT) 27 28 #include "StyleSheet.h" 29 30 #if !USE(QXMLQUERY) 31 #include <libxml/parser.h> 32 #include <libxslt/transform.h> 33 #endif 34 35 #include <wtf/PassRefPtr.h> 36 37 namespace WebCore { 38 39 class DocLoader; 40 class Document; 41 class XSLImportRule; 42 43 class XSLStyleSheet : public StyleSheet { 44 public: 45 #if !USE(QXMLQUERY) create(XSLImportRule * parentImport,const String & originalURL,const KURL & finalURL)46 static PassRefPtr<XSLStyleSheet> create(XSLImportRule* parentImport, const String& originalURL, const KURL& finalURL) 47 { 48 return adoptRef(new XSLStyleSheet(parentImport, originalURL, finalURL)); 49 } 50 #endif create(Node * parentNode,const String & originalURL,const KURL & finalURL)51 static PassRefPtr<XSLStyleSheet> create(Node* parentNode, const String& originalURL, const KURL& finalURL) 52 { 53 return adoptRef(new XSLStyleSheet(parentNode, originalURL, finalURL, false)); 54 } createInline(Node * parentNode,const KURL & finalURL)55 static PassRefPtr<XSLStyleSheet> createInline(Node* parentNode, const KURL& finalURL) 56 { 57 return adoptRef(new XSLStyleSheet(parentNode, finalURL.string(), finalURL, true)); 58 } 59 60 virtual ~XSLStyleSheet(); 61 isXSLStyleSheet()62 virtual bool isXSLStyleSheet() const { return true; } 63 type()64 virtual String type() const { return "text/xml"; } 65 66 virtual bool parseString(const String &string, bool strict = true); 67 68 virtual bool isLoading(); 69 virtual void checkLoaded(); 70 71 void loadChildSheets(); 72 void loadChildSheet(const String& href); 73 74 DocLoader* docLoader(); 75 ownerDocument()76 Document* ownerDocument() { return m_ownerDocument; } 77 void setParentStyleSheet(XSLStyleSheet* parent); 78 79 #if USE(QXMLQUERY) sheetString()80 String sheetString() const { return m_sheetString; } 81 #else 82 xmlDocPtr document(); 83 xsltStylesheetPtr compileStyleSheet(); 84 xmlDocPtr locateStylesheetSubResource(xmlDocPtr parentDoc, const xmlChar* uri); 85 #endif 86 87 void clearDocuments(); 88 89 void markAsProcessed(); processed()90 bool processed() const { return m_processed; } 91 92 private: 93 XSLStyleSheet(Node* parentNode, const String& originalURL, const KURL& finalURL, bool embedded); 94 #if !USE(QXMLQUERY) 95 XSLStyleSheet(XSLImportRule* parentImport, const String& originalURL, const KURL& finalURL); 96 #endif 97 98 Document* m_ownerDocument; 99 bool m_embedded; 100 bool m_processed; 101 102 #if USE(QXMLQUERY) 103 String m_sheetString; 104 #else 105 xmlDocPtr m_stylesheetDoc; 106 bool m_stylesheetDocTaken; 107 #endif 108 109 XSLStyleSheet* m_parentStyleSheet; 110 }; 111 112 } // namespace WebCore 113 114 #endif // ENABLE(XSLT) 115 116 #endif // XSLStyleSheet_h 117