From 7b1c5c9541a0b172f26e81f4a24e9bcbc177a1ed Mon Sep 17 00:00:00 2001 From: jez Date: Tue, 28 Apr 2009 08:57:14 +0100 Subject: [PATCH] started on literal result elements as stylesheet --- .../XSLT/impl/xslt_stylesheet_compiler.hpp | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/include/XSLT/impl/xslt_stylesheet_compiler.hpp b/include/XSLT/impl/xslt_stylesheet_compiler.hpp index 90da5e8c..f5d1910c 100755 --- a/include/XSLT/impl/xslt_stylesheet_compiler.hpp +++ b/include/XSLT/impl/xslt_stylesheet_compiler.hpp @@ -44,7 +44,11 @@ public: { if(top_) { - startStylesheet(namespaceURI, localName, qName, atts); + top_ = false; + if(namespaceURI == StylesheetConstant::NamespaceURI()) + startStylesheet(namespaceURI, localName, qName, atts); + else + startLREAsStylesheet(namespaceURI, localName, qName, atts); return; } // if(top_) @@ -86,8 +90,6 @@ private: const std::string& qName, const SAX::Attributes& atts) { - if(namespaceURI != StylesheetConstant::NamespaceURI()) - throw SAX::SAXException("The source file does not look like a stylesheet."); if(localName != "stylesheet" && localName != "transform") throw SAX::SAXException("Top-level element must be 'stylesheet' or 'transform'."); @@ -101,10 +103,28 @@ private: throw SAX::SAXException("I'm only a poor version 1.0 XSLT Transformer."); if(!attributes["extension-element-prefixes"].empty()) throw SAX::SAXException("Haven't implemented extension-element-prefixes yet"); - - top_ = false; } // startStylesheet + void startLREAsStylesheet(const std::string& namespaceURI, + const std::string& localName, + const std::string& qName, + const SAX::Attributes& atts) + { + std::string version; + for(int a = 0; a != atts.getLength(); ++a) + if((StylesheetConstant::NamespaceURI() == atts.getURI(a)) && + ("version" == atts.getLocalName(a))) + { + version = atts.getValue(a); + break; + } + + if(version.empty()) + throw SAX::SAXException("The source file does not look like a stylesheet."); + if(version != StylesheetConstant::Version()) + throw SAX::SAXException("I'm only a poor version 1.0 XSLT Transformer."); + } // startLREAsStylesheet + void startXSLTElement(const std::string& namespaceURI, const std::string& localName, const std::string& qName,