You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@apache.org on 2002/08/16 21:30:38 UTC
cvs commit: xml-xalan/c/src/XPath XPathProcessorImpl.cpp XPathProcessorImpl.hpp
dbertoni 2002/08/16 12:30:38
Modified: c/src/XPath XPathProcessorImpl.cpp XPathProcessorImpl.hpp
Log:
Support questionable namespace URIs by replacing prefixes with URIs after tokenization.
Revision Changes Path
1.58 +37 -3 xml-xalan/c/src/XPath/XPathProcessorImpl.cpp
Index: XPathProcessorImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathProcessorImpl.cpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- XPathProcessorImpl.cpp 26 Jun 2002 01:20:01 -0000 1.57
+++ XPathProcessorImpl.cpp 16 Aug 2002 19:30:38 -0000 1.58
@@ -93,7 +93,8 @@
m_prefixResolver(0),
m_requireLiterals(false),
m_isMatchPattern(false),
- m_positionPredicateStack()
+ m_positionPredicateStack(),
+ m_namespaces()
{
}
@@ -142,6 +143,7 @@
m_prefixResolver = 0;
m_locator = 0;
m_positionPredicateStack.clear();
+ m_namespaces.clear();
}
@@ -188,6 +190,7 @@
m_prefixResolver = 0;
m_locator = 0;
m_positionPredicateStack.clear();
+ m_namespaces.clear();
}
@@ -624,12 +627,32 @@
+void
+XPathProcessorImpl::replaceTokenWithNamespaceToken() const
+{
+ assert(m_xpath != 0);
+ assert(m_expression != 0);
+ assert(m_token.size() > 0);
+
+ StringToStringMapType::const_iterator i = m_namespaces.find(m_token);
+ assert(i != m_namespaces.end());
+
+ const XalanDOMString& theNamespaceURI = (*i).second;
+ assert(theNamespaceURI.size() != 0);
+
+ m_expression->replaceRelativeToken(
+ -1,
+ theNamespaceURI);
+}
+
+
+
int
XPathProcessorImpl::mapNSTokens(
const XalanDOMString& pat,
int startSubstring,
int posOfNSSep,
- int posOfScan) const
+ int posOfScan)
{
assert(m_prefixResolver != 0);
@@ -659,7 +682,9 @@
}
else
{
- addToTokenQueue(*uName);
+ m_namespaces[prefix] = *uName;
+
+ addToTokenQueue(prefix);
addToTokenQueue(DOMServices::s_XMLNamespaceSeparatorString);
@@ -1731,6 +1756,9 @@
XPathExpression::OpCodeMapValueVectorType theArgs(2, 0);
+ // Replace the token in the queue with the actual namespace URI...
+ replaceTokenWithNamespaceToken();
+
theArgs[0] = m_expression->getTokenPosition() - 1;
nextToken();
@@ -2078,6 +2106,9 @@
}
else
{
+ // Replace the token in the queue with the actual namespace...
+ replaceTokenWithNamespaceToken();
+
m_expression->pushCurrentTokenOnOpCodeMap();
}
@@ -2197,6 +2228,9 @@
}
else
{
+ // Replace the token in the queue with the actual namespace...
+ replaceTokenWithNamespaceToken();
+
m_expression->pushCurrentTokenOnOpCodeMap();
nextToken();
1.22 +11 -1 xml-xalan/c/src/XPath/XPathProcessorImpl.hpp
Index: XPathProcessorImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathProcessorImpl.hpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- XPathProcessorImpl.hpp 26 Jun 2002 01:20:01 -0000 1.21
+++ XPathProcessorImpl.hpp 16 Aug 2002 19:30:38 -0000 1.22
@@ -107,6 +107,9 @@
typedef map<XalanDOMString,
XPathExpression::eOpCodes,
less<XalanDOMString> > NodeTypesMapType;
+ typedef map<XalanDOMString,
+ XalanDOMString,
+ less<XalanDOMString> > StringToStringMapType;
typedef vector<XalanDOMString> DOMStringVectorType;
@@ -120,6 +123,8 @@
XPathExpression::eOpCodes> AxisNamesMapType;
typedef std::map<XalanDOMString,
XPathExpression::eOpCodes> NodeTypesMapType;
+ typedef std::map<XalanDOMString,
+ XalanDOMString> StringToStringMapType;
typedef std::vector<XalanDOMString> DOMStringVectorType;
@@ -195,6 +200,9 @@
void
addToTokenQueue(const XalanDOMString& s) const;
+ void
+ replaceTokenWithNamespaceToken() const;
+
/**
* When a separator token is found, see if there's a element name or the
* like to map.
@@ -204,7 +212,7 @@
const XalanDOMString& pat,
int startSubstring,
int posOfNSSep,
- int posOfScan) const;
+ int posOfScan);
/**
* Given a map pos, return the corresponding token queue pos.
@@ -826,6 +834,8 @@
const Locator* m_locator;
BoolVectorType m_positionPredicateStack;
+
+ StringToStringMapType m_namespaces;
enum eDummy
{
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org