Hi,
 
I am essentially using the code from SimpleXPathAPI sample in the Xalan-C_1_8_0-windows_2000-msvc_60 samples programs to evaluate a series of XPath expressions.  The XML document that I am evaluating the XPath expressions against uses a bunch of XML namespaces.  I find that even for elements in the default namespace I have to qualify the element name with the namespace prefix in the XPath _expression_ for it to work.  Is there any way to make XPathEvaluator() recognize element names without a prefix as being in the default namespace?
 
The code that I am using is:
 
  XalanSourceTreeDOMSupport  theDOMSupport;
  XalanSourceTreeParserLiaison theLiaison( theDOMSupport);
  theDOMSupport.setParserLiaison( &theLiaison);
 
  const XalanDOMString   theFileName( _fileName.c_str(), _fileName.length());
  const LocalFileInputSource  theInputSource( theFileName.c_str());
  XalanDocument* const   theDocument = theLiaison.parseXMLStream( theInputSource);
  assert( theDocument != 0);
  XalanDocumentPrefixResolver  thePrefixResolver( theDocument);
  XPathEvaluator     theEvaluator;
   XalanNode* xpathNode = getXPathEvaluator().selectSingleNode( getDOMSupport(), node,
     XalanDOMString( xpathIterator->getXPath().c_str()).c_str(), getPrefixResolver());
 
The XML document I am using is:
 

<FpML

version="4-1"

dswgVersion = "0-4"

xsi:type="dswg:PositionReport"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:fpml = "http://www.fpml.org/2004/FpML-4-1"

xmlns:dswg = "http://www.dswg.org/position-reporting"

xmlns:dsig = "http://www.w3.org/2000/09/xmldsig#"

xsi:schemaLocation="http://www.fpml.org/2004/FpML-4-1 schema/fpml-main-4-1.xsd http://www.dswg.org/position-reporting schema/dswg-0-4.xsd"

xmlns="http://www.fpml.org/2004/FpML-4-1">

 
The XPath I am trying to evaluate is:
 

dswg:positionSummary/fpml:equitySwap/fpml:productType

"fpml" is the default namespace.  But if I remove the prefix from the _expression_ above it doesn't work.

Is there any way to make the following evaluate properly?

dswg:positionSummary/equitySwap/productType

 

Thanks,

Sanjoy

Reply via email to