XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Using Schematron to express a rule for a QName value?

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]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS