W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2002

Select specific node and namespaces

From: Snow, Corey <csnow@deltadentalwa.com>
Date: Tue, 11 Jun 2002 13:34:19 -0400 (EDT)
Message-ID: <BEF83059BBECD511B9270008C7490A590A4DD4@skunk.ddpwa.com>
To: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>




I've got a minor problem, and I'm hoping there's a simple answer.

First, the background: I've got a set of XML schema documents that I use to
validate instance documents in a content-replication system. I also have
Schematron rules embedded in these documents. When content is replicated, I
validate the document against the XML schema, then if successful, against
the Schematron rules.

All pretty straightforward so far, I'd guess. However, when a node fails to
be validated against the Schematron rules, I'd like to replace it. My
validating stylesheet, generated by schematron-xml.xsl, produces output that
contains a "failed-assert" node for each instance node that failed to be
validated for whatever reason. One of the properties of the failed-assert
node is a property called "Location". It contains something like the
following:

/topic[1]/content[1]/para[1]/link[1]

Which is the location in the instance document where the validation failed.
I'm trying to write a script that will replace this node. The instance
document is in a namespace of my own definition. When I try to select the
failed node using the Location attribute, it fails, apparently because it
can't find the namespace. I'm using MSXML 4.0. If I do something like this
(pseudocode):

objXMLDoc.replaceChild objErrNode,
objXMLDoc.selectSingleNode("/topic[1]/content[1]/para[1]/link[1]")

It fails, because objXMLDoc has a namespace, which is not represented by the
XPath query, so the selectSingleNode call returns NULL. However, if I add
the namespace before the query:

objXMLDoc.setProperty "SelectionNamespaces", "xmlns:myns="mynamespaceURN"

It still fails unless I modify the XPath to something like:
/myns:topic[1]/myns:content[1]/myns:para[1]/myns:link[1]

I guess my question is, how can I select a node in this fashion without
having to modify the Location string so much? I could simply replace all the
"/" characters with "/myns:" but that just seems kludgy. I have a feeling
that this is the result of my limited experience with XPath.

Another thing I'm considering is trying to modify "schematron-xml.xsl" so it
generates fully namespace-qualified XPath, but I'd prefer not to do that
unless I have to. I don't think it would be very portable.

Any comments or suggestions would be welcome-

Thank you,

Corey Snow

#########################################################
The information contained in this e-mail and subsequent attachments may be privileged, 
confidential and protected from disclosure.  This transmission is intended for the sole 
use of the individual and entity to whom it is addressed.  If you are not the intended 
recipient, any dissemination, distribution or copying is strictly prohibited.  If you 
think that you have received this message in error, please e-mail the sender at the above 
e-mail address.
#########################################################
Received on Tuesday, 11 June 2002 17:08:06 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:31 GMT