the context element

Post here issues about NVDL, not specifically linked to the oNVDL implementation.
queshaw
Posts: 41
Joined: Wed Aug 08, 2007 5:56 am

the context element

Post by queshaw »

As far as I can tell, the spec doesn't describe the context element. Does it qualify the next mode to use based on the name of an element within the section being validated?

I thought this might work (allow p to be validated by b.rnc instead of a.rnc):

a.rnc:

namespace a = "http://a"
start = doc
doc = element a:doc { sec }
sec = element a:sec { p }
p = element a:p { text }

b.rnc:

namespace a = "http://a"
start = p
p = element a:p { quote }
quote = element a:quote { text }

an.nvdl

<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" xmlns:a="http://a">
<anyNamespace>
<validate schema="a.rnc" schemaType="application/x-rnc">
<context path="p">
<mode>
<anyNamespace>
<validate schema="b.rnc" schemaType="application/x-rnc">
<mode><anyNamespace><reject/></anyNamespace></mode>
</validate>
</anyNamespace>
</mode>
</context>
</validate>
</anyNamespace>
</rules>

test.xml:

<doc xmlns="http://a">
<sec>
<p>
<quote>Floop</quote>
</p>
</sec>
</doc>

If I use oxygen to validate, it says unknown element quote from namespace http://a.
queshaw
Posts: 41
Joined: Wed Aug 08, 2007 5:56 am

Post by queshaw »

I think I understand what context is for, based on this from the NRL tutorial:

http://www.thaiopensource.com/relaxng/n ... me_context

So, in my example, if I remove the p element from b.rnc, make quote be the root element and use a different namespace, then it restricts quote to being a child of {http://a}p:

b.rnc:

namespace b = "http://b"
start = element b:quote { text }

an.nvdl:

<?xml version="1.0" encoding="UTF-8"?>
<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0" schemaType="application/x-rnc"
startMode="a">
<mode name="a">
<namespace ns="http://a">
<validate schema="a.rnc">
<context path="p" useMode="b"/>
</validate>
</namespace>
</mode>
<mode name="b">
<namespace ns="http://b">
<validate schema="b.rnc"/>
</namespace>
</mode>
</rules>

Append child in oxygen still suggests quote in places where it doesn't belong though.
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi,

The NVDL rules are applied on the sections. The sections are obtained only based on the namespaces and trigger elements. So, if you have all elements in the same namespace and no triggers you will get only one section and the same processing will be applied to all the content of the section.

Best Regards,
George
George Cristian Bina
Post Reply