- From: Francis Norton <francis@redrice.com>
- Date: Wed, 12 Jun 2002 14:27:24 +0100
- To: "Snow, Corey" <csnow@deltadentalwa.com>
- CC: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>, Rick Jelliffe <ricko@topologi.com>
Hi Corey, Snow, Corey wrote: >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] > > presumably these elements are in the default namespace. I hadn't realised that name() returns an unqualified name for nodes that are in a non-blank default namespace. <snip/> >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] > Have you tried: objXMLDoc.setProperty "SelectionNamespaces", "xmlns=mynamespaceURN" to set the default namespace? Don't worry if it doesn't work, see below... >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 > Well, you could replace the template in skeleton1-5.xsl with this one line mod: <!-- utility routine for implementations --> <axsl:template match="*|@*" mode="schematron-get-full-path"> <axsl:apply-templates select="parent::*" mode="schematron-get-full-path"/> <axsl:text>/</axsl:text> <axsl:if test="count(. | ../@*) = count(../@*)">@</axsl:if> <axsl:if test="not(namespace-uri(.)='') and not(contains(name(.), ':'))">_dns:</axsl:if> <axsl:value-of select="name()"/> <axsl:text>[</axsl:text> <axsl:value-of select="1+count(preceding-sibling::*[name()=name(current())])"/> <axsl:text>]</axsl:text> </axsl:template> It's a bit of a hack since it arbitrarily associates the prefix "_dns:" with what was the default namespace - I'd be open to better suggestions. Francis.
Received on Wednesday, 12 June 2002 09:29:31 UTC