dbertoni 01/01/30 17:42:20
Modified: c/src/XSLT ElemTemplateElement.hpp FunctionDocument.cpp Stylesheet.hpp StylesheetExecutionContextDefault.cpp StylesheetExecutionContextDefault.hpp XSLTEngineImpl.cpp XSLTEngineImpl.hpp Log: Changes necessary for moving PrefixResolver.cpp and PrefixResolver.hpp to DOMSupport. Changes to implement namespace-aware processing with HTML output. Revision Changes Path 1.21 +1 -1 xml-xalan/c/src/XSLT/ElemTemplateElement.hpp Index: ElemTemplateElement.hpp =================================================================== RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemTemplateElement.hpp,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- ElemTemplateElement.hpp 2000/11/02 22:26:00 1.20 +++ ElemTemplateElement.hpp 2001/01/31 01:42:19 1.21 @@ -80,7 +80,7 @@ -#include <XPath/PrefixResolver.hpp> +#include <DOMSupport/PrefixResolver.hpp> 1.23 +1 -1 xml-xalan/c/src/XSLT/FunctionDocument.cpp Index: FunctionDocument.cpp =================================================================== RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionDocument.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- FunctionDocument.cpp 2000/12/06 21:19:20 1.22 +++ FunctionDocument.cpp 2001/01/31 01:42:20 1.23 @@ -68,11 +68,11 @@ #include <DOMSupport/DOMServices.hpp> +#include <DOMSupport/PrefixResolver.hpp> #include <XPath/XObjectFactory.hpp> -#include <XPath/PrefixResolver.hpp> 1.31 +4 -1 xml-xalan/c/src/XSLT/Stylesheet.hpp Index: Stylesheet.hpp =================================================================== RCS file: /home/cvs/xml-xalan/c/src/XSLT/Stylesheet.hpp,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- Stylesheet.hpp 2000/12/21 04:48:30 1.30 +++ Stylesheet.hpp 2001/01/31 01:42:20 1.31 @@ -79,7 +79,10 @@ #include <XalanDOM/XalanNodeListSurrogate.hpp> -#include <XPath/PrefixResolver.hpp> +#include <DOMSupport/PrefixResolver.hpp> + + + #include <XPath/NameSpace.hpp> #include <XPath/QNameByReference.hpp> 1.54 +9 -0 xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp Index: StylesheetExecutionContextDefault.cpp =================================================================== RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp,v retrieving revision 1.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- StylesheetExecutionContextDefault.cpp 2001/01/29 02:30:31 1.53 +++ StylesheetExecutionContextDefault.cpp 2001/01/31 01:42:20 1.54 @@ -146,6 +146,7 @@ m_keyDeclarationSet(), m_countersTable(), m_useDOMResultTreeFactory(false), + m_ignoreHTMLElementNamespaces(false), m_sourceTreeResultTreeFactory() { } @@ -1063,6 +1064,14 @@ version, standalone, xmlDecl); + + // Check to see if the user has asked us to ignore + // namespaces in HTML output. + if (m_ignoreHTMLElementNamespaces == false) + { + // Nope, so give the formatter a prefix resolver... + theFormatter->setPrefixResolver(&m_xsltProcessor); + } m_formatterListeners.insert(theFormatter); 1.48 +35 -1 xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp Index: StylesheetExecutionContextDefault.hpp =================================================================== RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- StylesheetExecutionContextDefault.hpp 2001/01/29 02:30:31 1.47 +++ StylesheetExecutionContextDefault.hpp 2001/01/31 01:42:20 1.48 @@ -170,7 +170,7 @@ * Set the value of the flag that controls whether result tree * fragments are created using a DOM factory, or a XalanSourceTreeDocument. * - * @param The boolean value + * @param theValue The boolean value */ void setUseDOMResultTreeFactory(bool theValue) @@ -178,7 +178,36 @@ m_useDOMResultTreeFactory = theValue; } + /** + * Set the value of the flag that controls whether HTML output will + * check for namespace declarations on HTML elements. + * + * Set this to true if you want the HTML output formatter to skip + * checking for namespaces on elements. This makes HTML output more + * efficient, but can result in non-conforming behavior, since the XSLT + * recommendation requires XML output for elements with namespaces. + * + * @param theValue The boolean value + */ + bool + setIgnoreHTMLElementNamespaces() const + { + return m_ignoreHTMLElementNamespaces; + } + + /** + * Set the value of the flag that controls whether HTML output will + * check for namespace declarations on HTML elements. + * + * @return The value + */ + void + setIgnoreHTMLElementNamespaces(bool theValue) + { + m_ignoreHTMLElementNamespaces = theValue; + } + // These interfaces are inherited from StylesheetExecutionContext... virtual bool @@ -904,6 +933,11 @@ CountersTable m_countersTable; bool m_useDOMResultTreeFactory; + + // If true, we will not check HTML output for elements with + // namespaces. This is an optimization which can lead to + // non-conforming behavior. + bool m_ignoreHTMLElementNamespaces; /** * The factory that will be used to create result tree fragments based on our 1.84 +21 -0 xml-xalan/c/src/XSLT/XSLTEngineImpl.cpp Index: XSLTEngineImpl.cpp =================================================================== RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTEngineImpl.cpp,v retrieving revision 1.83 retrieving revision 1.84 diff -u -r1.83 -r1.84 --- XSLTEngineImpl.cpp 2001/01/30 22:03:40 1.83 +++ XSLTEngineImpl.cpp 2001/01/31 01:42:20 1.84 @@ -152,6 +152,10 @@ +const XalanDOMString XSLTEngineImpl::s_emptyString; + + + //========================================================== // SECTION: Constructors //========================================================== @@ -164,6 +168,7 @@ XPathFactory& xpathFactory) : XSLTProcessor(), DocumentHandler(), + PrefixResolver(), m_outputCarriageReturns(false), m_outputLinefeeds(false), m_useDOMResultTreeFactory(false), @@ -585,6 +590,22 @@ } return sourceTree; +} + + + +const XalanDOMString& +XSLTEngineImpl::getNamespaceForPrefix(const XalanDOMString& prefix) const +{ + return m_resultNamespacesStack.getNamespaceForPrefix(prefix); +} + + + +const XalanDOMString& +XSLTEngineImpl::getURI() const +{ + return s_emptyString; } 1.61 +30 -2 xml-xalan/c/src/XSLT/XSLTEngineImpl.hpp Index: XSLTEngineImpl.hpp =================================================================== RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTEngineImpl.hpp,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- XSLTEngineImpl.hpp 2001/01/30 22:03:41 1.60 +++ XSLTEngineImpl.hpp 2001/01/31 01:42:20 1.61 @@ -101,6 +101,10 @@ +#include <DOMSupport/PrefixResolver.hpp> + + + #include <XPath/Function.hpp> #include <XPath/NameSpace.hpp> @@ -149,7 +153,7 @@ * */ -class XALAN_XSLT_EXPORT XSLTEngineImpl : public XSLTProcessor, private DocumentHandler +class XALAN_XSLT_EXPORT XSLTEngineImpl : public XSLTProcessor, private DocumentHandler, public PrefixResolver { public: @@ -201,7 +205,8 @@ XObjectFactory& xobjectFactory, XPathFactory& xpathFactory); - virtual ~XSLTEngineImpl(); + virtual + ~XSLTEngineImpl(); /** * Perform initialization of statics -- must be called before any @@ -333,6 +338,27 @@ setDiagnosticsOutput(PrintWriter* pw); + // Inherited from PrefixResolver... + + /** + * Retrieve a namespace corresponding to a prefix. This assumes that + * the PrevixResolver hold's its own namespace context, or is a namespace + * context itself. + * + * @param prefix Prefix to resolve + * @return namespace that prefix resolves to, or null if prefix is not found + */ + virtual const XalanDOMString& + getNamespaceForPrefix(const XalanDOMString& prefix) const; + + /** + * Retrieve the base URI for the resolver. + * + * @return URI string + */ + virtual const XalanDOMString& + getURI() const; + /** * Read in the XML file, either producing a Document or calling SAX events, * and register the document in a table. If the document has already been @@ -1679,6 +1705,8 @@ static void initializeXSLT4JElementKeys(ElementKeysMapType& theElementKeys); + + static const XalanDOMString s_emptyString; };