dbertoni 00/06/27 14:00:27
Modified: c/src/XSLT XSLTEngineImpl.cpp XSLTEngineImpl.hpp
Log:
Fixed fetching stylesheet URI from PI. General cleanup.
Revision Changes Path
1.46 +87 -122 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.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- XSLTEngineImpl.cpp 2000/06/14 21:40:08 1.45
+++ XSLTEngineImpl.cpp 2000/06/27 21:00:20 1.46
@@ -196,7 +196,6 @@
m_resultTreeFactory(0),
m_resultNameSpacePrefix(),
m_resultNameSpaceURL(),
- m_stylesheets(),
m_currentNode(),
m_pendingElementName(),
m_pendingAttributes(),
@@ -218,9 +217,7 @@
m_diagnosticsPrintWriter(0),
m_durationsTable(),
m_traceListeners(),
- m_outputFileName(),
m_uniqueNSValue(0),
- m_useATVsInSelects(false),
m_stripWhiteSpace(false),
m_topLevelParams(),
m_parserLiaison(parserLiaison),
@@ -228,7 +225,6 @@
m_xpathEnvSupport(xpathEnvSupport),
m_flistener(0),
m_contextNodeList(&xpathSupport),
- m_namedTemplates(),
m_topLevelVariables(),
m_executionContext(0),
m_needToCheckForInfiniteLoops(false),
@@ -382,8 +378,21 @@
// Didn't get a stylesheet from the input source, so
look for a
// stylesheet processing instruction...
XalanDOMString stylesheetURI = 0;
+
+ // Find the first element, and assume that it's the
document element.
XalanNode* child =
sourceTree->getFirstChild();
+ while(child != 0 && child->getNodeType() !=
XalanNode::ELEMENT_NODE)
+ {
+ child = child->getNextSibling();
+ }
+
+ // OK, if we found a document element, start with the
first child.
+ if(child != 0)
+ {
+ child = child->getFirstChild();
+ }
+
#if !defined(XALAN_NO_NAMESPACES)
using std::vector;
#endif
@@ -539,7 +548,7 @@
StylesheetRoot*
XSLTEngineImpl::processStylesheet(
- const XalanDOMString&
xsldocURLString,
+ const XalanDOMString& xsldocURLString,
StylesheetConstructionContext& constructionContext)
{
try
@@ -565,57 +574,63 @@
XSLTInputSource&
stylesheetSource,
StylesheetConstructionContext& constructionContext)
{
- const XalanDOMString ds(XALAN_STATIC_UCODE_STRING("Input XSL"));
- const XalanDOMString xslIdentifier(0 ==
stylesheetSource.getSystemId() ?
- ds :
stylesheetSource.getSystemId());
-
StylesheetRoot* theStylesheet = 0;
- // In case we have a fragment identifier, go ahead and
- // try to parse the XML here.
- try
- {
- theStylesheet = constructionContext.create(stylesheetSource);
+ const XalanDOMChar* const systemID =
stylesheetSource.getSystemId();
+ XalanNode* const stylesheetNode =
stylesheetSource.getNode();
- StylesheetHandler stylesheetProcessor(*theStylesheet,
constructionContext);
+ if (systemID != 0 || stylesheetNode != 0)
+ {
+ XalanDOMString xslIdentifier;
- if(0 != stylesheetSource.getNode())
+ try
{
- FormatterTreeWalker tw(stylesheetProcessor);
+ theStylesheet =
constructionContext.create(stylesheetSource);
+
+ StylesheetHandler
stylesheetProcessor(*theStylesheet, constructionContext);
+
+ if(stylesheetNode != 0)
+ {
+ xslIdentifier =
XALAN_STATIC_UCODE_STRING("Input XSL");
- tw.traverse(stylesheetSource.getNode());
+ FormatterTreeWalker tw(stylesheetProcessor);
+
+ tw.traverse(stylesheetSource.getNode());
+ }
+ else
+ {
+ assert(systemID != 0);
+
+ xslIdentifier = systemID;
+
+ diag(XALAN_STATIC_UCODE_STRING("=========
Parsing ") + xslIdentifier + XALAN_STATIC_UCODE_STRING(" =========="));
+ pushTime(&xslIdentifier);
+ m_parserLiaison.parseXMLStream(stylesheetSource,
+
stylesheetProcessor);
+ if(0 != m_diagnosticsPrintWriter)
+
displayDuration(XALAN_STATIC_UCODE_STRING("Parse of ") + xslIdentifier,
&xslIdentifier);
+ }
}
- else
+ catch(const XSLException&)
{
- diag(XALAN_STATIC_UCODE_STRING("========= Parsing ") +
xslIdentifier + XALAN_STATIC_UCODE_STRING(" =========="));
- pushTime(&xslIdentifier);
- m_parserLiaison.parseXMLStream(stylesheetSource,
-
stylesheetProcessor);
- if(0 != m_diagnosticsPrintWriter)
-
displayDuration(XALAN_STATIC_UCODE_STRING("Parse of ") + xslIdentifier,
&xslIdentifier);
- }
- }
- catch(const XSLException&)
- {
- message("Error parsing " + xslIdentifier);
+ message("Error parsing " + xslIdentifier);
- throw;
- }
- catch(const SAXException&)
- {
- message("Error parsing " + xslIdentifier);
+ throw;
+ }
+ catch(const SAXException&)
+ {
+ message("Error parsing " + xslIdentifier);
- throw;
- }
- catch(const XMLException&)
- {
- message("Error parsing " + xslIdentifier);
+ throw;
+ }
+ catch(const XMLException&)
+ {
+ message("Error parsing " + xslIdentifier);
- throw;
+ throw;
+ }
}
- m_stylesheetRoot = theStylesheet;
-
return theStylesheet;
}
@@ -3158,7 +3173,15 @@
const XalanDOMString
XSLTEngineImpl::getUniqueNSValue() const
{
- return XALAN_STATIC_UCODE_STRING("ns") +
LongToDOMString(m_uniqueNSValue++);
+#if defined(XALAN_NO_MUTABLE)
+ const unsigned long temp = m_uniqueNSValue;
+
+ ((XSLTEngineImpl*)this)->m_uniqueNSValue++;
+
+ return XALAN_STATIC_UCODE_STRING("ns") + UnsignedLongToDOMString(temp);
+#else
+ return XALAN_STATIC_UCODE_STRING("ns") +
UnsignedLongToDOMString(m_uniqueNSValue++);
+#endif
}
@@ -3282,81 +3305,6 @@
-const XalanDOMString
-XSLTEngineImpl::getStyleSheetURIFromDoc(const XalanNode& sourceTree)
-{
- XalanDOMString stylesheetURI;
-
- const XalanNode* child = sourceTree.getFirstChild();
-
- // $$$ ToDo: is this first one still valid?
- const XalanDOMString
stylesheetNodeName1(XALAN_STATIC_UCODE_STRING("xml-stylesheet"));
- const XalanDOMString
stylesheetNodeName2(XALAN_STATIC_UCODE_STRING("xml:stylesheet"));
-
- // $$$ ToDo: This code is much like that in process().
- // Why is it repeated???
- // $$$ ToDo: Move these embedded strings from inside these loops
- // out here...
- // $$$ ToDo: These loops are a mess of repeated use of the
- // same data values.
- while(child != 0)
- {
- if(XalanNode::PROCESSING_INSTRUCTION_NODE ==
child->getNodeType())
- {
- const XalanDOMString nodeName(child->getNodeName());
-
- if(equals(nodeName, stylesheetNodeName1) ||
- equals(nodeName, stylesheetNodeName2))
- {
- bool isOK = true;
-
- const XalanDOMString
nodeValue(child->getNodeValue());
-
- StringTokenizer
tokenizer(nodeValue, XALAN_STATIC_UCODE_STRING(" \t="));
-
- while(tokenizer.hasMoreTokens() == true)
- {
- const XalanDOMString
nextToken(tokenizer.nextToken());
-
- if(equals(nextToken,
XALAN_STATIC_UCODE_STRING("type")) == true)
- {
- const XalanDOMString typeVal
=
- substring(nextToken, 1,
length(nextToken) - 1);
-
- if(equals(typeVal,
XALAN_STATIC_UCODE_STRING("text/xsl")) == false)
- {
- isOK = false;
- }
- }
- }
-
- if(isOK == true)
- {
- StringTokenizer
tokenizer(nodeValue, XALAN_STATIC_UCODE_STRING(" \t="));
-
- while(tokenizer.hasMoreTokens() == true)
- {
- const XalanDOMString
nextToken(tokenizer.nextToken());
-
- if(equals(nextToken,
XALAN_STATIC_UCODE_STRING("href")))
- {
- stylesheetURI =
-
substring(nextToken, 1, nextToken.length() - 1);
- }
- }
- break;
- }
- }
- }
-
- child = child->getNextSibling();
- }
-
- return stylesheetURI;
-}
-
-
-
void
XSLTEngineImpl::setStylesheetParam(
const XalanDOMString& theName,
@@ -3413,7 +3361,7 @@
const XalanDOMString& /* codetype */)
{
#if 1
- error("Xalan does not support extensions at this time!");
+ error("Xalan C++ does not support extensions at this time!");
#else
try
{
@@ -3459,7 +3407,7 @@
DispatcherFactory* /* factory */)
{
#if 1
- error("Xalan does not support extensions at this time!");
+ error("Xalan C++ does not support extensions at this time!");
#else
if(0 != m_diagnosticsPrintWriter)
{
@@ -3620,9 +3568,13 @@
if(theType == XalanNode::TEXT_NODE)
{
+#if defined(XALAN_OLD_STYLE_CASTS)
+ const XalanText* const tx =
+ (const XalanText*)m_sourceXML;
+#else
const XalanText* const tx =
static_cast<const XalanText*>(m_sourceXML);
-
+#endif
pw.println(tx->getData());
}
else if(theType == XalanNode::ELEMENT_NODE)
@@ -3701,6 +3653,19 @@
m_stack.pop_back();
}
+
+
+
+XSLTEngineImpl::XSLInfiniteLoopException::XSLInfiniteLoopException() :
+ XSLTProcessorException("XSLT infinite loop occurred!")
+{
+}
+
+
+
+XSLTEngineImpl::XSLInfiniteLoopException::~XSLInfiniteLoopException()
+{
+}
1.36 +8 -114 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.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- XSLTEngineImpl.hpp 2000/06/01 16:28:37 1.35
+++ XSLTEngineImpl.hpp 2000/06/27 21:00:21 1.36
@@ -171,10 +171,6 @@
typedef XALAN_STD map<const XalanNode*, int> XSLDirectiveMapType;
- typedef XALAN_STD map<XalanDOMString,
- const XalanNode*>
NamedTemplatesMapType;
- typedef XALAN_STD map<XalanDOMString,
- Stylesheet*>
StylesheetMapType;
#undef XALAN_STD
typedef Function::XObjectArgVectorType XObjectArgVectorType;
@@ -241,7 +237,8 @@
* Perform initialization of statics -- must be called before any
* processing occurs
*/
- static void Initialize();
+ static void
+ Initialize();
// These methods are inherited from XSLTProcessor ...
@@ -628,23 +625,6 @@
setExecutionContext(StylesheetExecutionContext*
theExecutionContext);
/**
- * Table of stylesheet documents. Document objects are keyed by URL
string.
- */
- StylesheetMapType m_stylesheets;
-
- /**
- * Get table of stylesheet documents. Document objects are keyed by URL
- * string.
- *
- * @return stylesheets table
- */
- StylesheetMapType&
- getStylesheetsTable()
- {
- return m_stylesheets;
- }
-
- /**
* Retrieve the URI for the current XSL namespace, for example,
* "http://www.w3.org/1999/XSL/Transform"
*
@@ -1194,32 +1174,6 @@
getNormalizedText(const XalanText& tx) const;
/**
- * Get the filename of the output document, if it was set. This is for
use
- * by multiple output documents, to determine the base directory for the
- * output document. It needs to be set by the caller.
- *
- * @return name of output document
- */
- const XalanDOMString&
- getOutputFileName() const
- {
- return m_outputFileName;
- }
-
- /**
- * Set the filename of the output document. This is for use by multiple
- * output documents, to determine the base directory for the output
- * document. It needs to be set by the caller.
- *
- * @param filename name of output document
- */
- void
- setOutputFileName(const XalanDOMString& filename)
- {
- m_outputFileName = filename;
- }
-
- /**
* Get the factory for making xpaths.
*
* @return XPath factory object
@@ -1242,17 +1196,6 @@
}
/**
- * Given a document, get the default stylesheet URI from the
xsl:stylesheet
- * PI. However, this will only get you the first URL, and there may be
- * many.
- *
- * @param sourceTree node for source tree
- * @deprecated
- */
- const XalanDOMString
- getStyleSheetURIFromDoc(const XalanNode& sourceTree);
-
- /**
* Given a classID and codetype, try to register a code dispatcher.
*
* @param classid class id for extension
@@ -1318,41 +1261,6 @@
}
/**
- * Add a named template to the table of template name and value pairs.
- *
- * @param theName name of template
- * @param theNode template node
- */
- void
- addNamedTemplate(const XalanDOMString& theName,
- const XalanNode* theNode)
- {
- m_namedTemplates[theName] = theNode;
- }
-
- /**
- * Find a named template in the table of template name and value pairs.
- *
- * @param theName name of template
- * @return template node if found, empty node otherwise
- */
- const XalanNode*
- getNamedTemplate(const XalanDOMString& theName) const
- {
- const NamedTemplatesMapType::const_iterator i =
- m_namedTemplates.find(theName);
-
- if(i != m_namedTemplates.end())
- {
- return (*i).second;
- }
- else
- {
- return 0;
- }
- }
-
- /**
* Set the problem listener property. The XSL class can have a single
* listener that can be informed of errors and warnings, and can
normally
* control if an exception is thrown or not (or the problem listeners
can
@@ -1427,8 +1335,10 @@
class XSLInfiniteLoopException : public XSLTProcessorException
{
public:
- XSLInfiniteLoopException() : XSLTProcessorException("XSLT
infinite loop occurred!")
- { }
+ XSLInfiniteLoopException();
+
+ virtual
+ ~XSLInfiniteLoopException();
};
/**
@@ -2082,13 +1992,6 @@
const XalanNode*
styleNode = 0,
const XalanNode*
sourceNode = 0) const;
- /**
- * This is for use by multiple output documents, to determine
- * the base directory for the output document. It needs to
- * be set by the caller.
- */
- XalanDOMString m_outputFileName;
-
//==========================================================
// SECTION: Function to do with attribute handling
@@ -2097,7 +2000,7 @@
/**
* This is used whenever a unique namespace is needed.
*/
- mutable int m_uniqueNSValue; // 0
+ mutable unsigned long m_uniqueNSValue; // 0
/**
* This should probably be in the XMLParserLiaison interface.
@@ -2107,8 +2010,6 @@
const XalanDOMString& theNamespace,
const XalanElement& namespaceContext) const;
- bool m_useATVsInSelects;
-
/**
* Translate CSS attributes and put them in a style tag.
* @deprecated
@@ -2266,16 +2167,9 @@
MutableNodeRefList m_contextNodeList;
/**
- * Keyed on string macro names, and holding values that are macro
elements
- * in the XSL DOM tree. Initialized in initMacroLookupTable, and used in
- * findNamedTemplate.
- */
- NamedTemplatesMapType m_namedTemplates;
-
- /**
* Table for defined constants, keyed on the names.
*/
- TopLevelVariablesMapType m_topLevelVariables;
+ TopLevelVariablesMapType m_topLevelVariables;
StylesheetExecutionContext* m_executionContext;