[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Using Schematron to express a rule for a QName value?
- From: "Costello, Roger L." <costello@mitre.org>
- To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
- Date: Fri, 21 Sep 2012 15:40:29 +0000
Hi Folks,
Consider the following XML document. There is an <Item> element which has a "name" attribute:
<Test xmlns:wid="http://www.widget.org">
<Item name="wid:widget" />
</Test>
The value of @name is a QName.
I want a Schematron rule that expresses this:
The <Item> element must have a
name attribute whose value is "widget"
in the http://www.widget.org namespace.
(The value of @name is a QName)
So I created this Schematron document:
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:w="http://www.widget.org"
queryBinding="xslt2">
<sch:pattern id="QName-Test">
<sch:rule context="Item">
<sch:assert test="resolve-QName(@name, .) eq xsd:QName('w:widget')">
The value of the name attribute must
be 'widget' in the http://www.widget.org
namespace.
</sch:assert>
</sch:rule>
</sch:pattern>
</sch:schema>
When I validated the XML document against the Schematron schema I got this error:
Namespace prefix {w} has not been declared
Any ideas on what the problem is?
/Roger
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]