You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by 장승필 <fr...@iasecurity.com> on 2002/07/01 11:18:34 UTC
XPath with namespaces
Hi, all.
I want to get the special element.
I have that xml file.
-------------------------
<?xml .... ?>
<dsig:Signature xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">
<dsig:SignedInfo xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">
....
</dsig:Signature>
--------------------------
And, I get the 'Signature' element.
So I use the xpath expression like this, "/descendant-or-self::dsig:Signature"
But, My app throws a exception.
My code..
---------------------------------------------
char* strSchema = "http://www.w3.org/2000/09/xmldsig# D:\\xmldsig.xsd" ;
DOMParser* parser = new DOMParser;
DOMParser::ValSchemes valScheme = DOMParser::Val_Always;
bool doNamespaces = true;
bool doSchema = true;
bool schemaFullChecking = true;
parser->setValidationScheme(valScheme);
parser->setDoNamespaces(doNamespaces);
parser->setDoSchema(doSchema);
parser->setExternalSchemaLocation(strSchema) ;
parser->setValidationSchemaFullChecking(schemaFullChecking);
parser->parse(xmlFile);
DOM_Document doc = parser->getDocument() ;
XercesDOMSupport* support = new XercesDOMSupport() ;
XercesDOMSupport theDOMSupport ;
XercesParserLiaison theLiaison(theDOMSupport) ;
XalanDocument* theDocument = theLiaison.createDocument(doc) ;
XPathEvaluator theEvaluator;
XalanNode* const theContextNode = theDocument->getDocumentElement() ;
const char* xpathstr = "/descendant-or-self::dsig:Signature" ;
const XObjectPtr result = theEvaluator.evaluate(*support, theContextNode,
XalanDOMString(xpathstr).c_str(), theContextNode) ; // <-- throw exception
.....................