Hi Folks,
I think that I understand the purpose of triggers: sometimes you want
to perform a finer level of processing than "process uniformly
everything in this namespace." With triggers, what would ordinarily be
one section, can be decomposed into several parts.
Here is an example I created to demonstrate a use of triggers.
This Book is comprised of one namespace (thus, one section):
-----------------------------------------------------
Book.xml
-----------------------------------------------------
<?xml version="1.0"?>
<Book xmlns="http://www.book.org <http://www.book.org/> ">
<Title>The Wisdom of Crowds</Title>
<Author>James Surowiecki</Author>
<Date>2005</Date>
<ISBN>0-385-72170-6</ISBN>
<Publisher>Anchor Books</Publisher>
</Book>
There is a schema, Book.rng, which can be used to validate this
section. (The schema is below). The schema declares all the leaf nodes
to be of the string data type.
There is another schema, Publisher.xsd, which restricts the <Publisher>
element to a small set of values. And this schema is for the same
namespace. (This schema is also shown below)
I want to decompose the Book section using a trigger. For the
<Publisher> element I want it validated using Publisher.xsd, and the
rest of the Book section should be validated using Book.rng.
Below is my NVDL to accomplish this. I get several errors when I try
to run this. What am I doing wrong please? Is this a proper use of
triggers?
Thanks!
/Roger
-----------------------------------------------------
Book.nvdl
-----------------------------------------------------
<?xml version="1.0"?>
<rules startMode="book"
xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0">
<trigger ns="http://www.book.org"
nameList="Publisher" />
<mode name="book">
<namespace ns="http://www.book.org">
<validate schema="Book.rng"
useMode="publisher" />
</namespace>
</mode>
<mode name="publisher">
<namespace ns="http://www.book.org">
<validate schema="Publisher.xsd"/>
</namespace>
</mode>
</rules>
-----------------------------------------------------
Book.rng
-----------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<element name="Book"
xmlns="http://relaxng.org/ns/structure/1.0"
ns="http://www.book.org">
<element name="Title">
<text/>
</element>
<element name="Author">
<text/>
</element>
<element name="Date">
<text/>
</element>
<element name="ISBN">
<text/>
</element>
<element name="Publisher">
<text/>
</element>
</element>
-----------------------------------------------------
Publisher.xsd
-----------------------------------------------------
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.book.org"
elementFormDefault="qualified">
<element name="Publisher">
<simpleType>
<restriction base="string">
<enumeration value="Anchor Books"/>
</restriction>
</simpleType>
</element>
</schema>
-- DSDL comments To unsubscribe, please send a message with the command "unsubscribe" to dsdl-comment-request@dsdl.org (mailto:dsdl-comment-request@dsdl.org?Subject=unsubscribe)Received on Wed May 28 02:26:26 2008
This archive was generated by hypermail 2.1.8 : Wed May 28 2008 - 01:38:06 UTC