Page 1 of 1

the context element

Posted: Thu Aug 09, 2007 12:21 am
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):


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


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


<rules xmlns="" xmlns:a="http://a">
<validate schema="a.rnc" schemaType="application/x-rnc">
<context path="p">
<validate schema="b.rnc" schemaType="application/x-rnc">


<doc xmlns="http://a">

If I use oxygen to validate, it says unknown element quote from namespace http://a.

Posted: Thu Aug 09, 2007 6:42 am
by queshaw
I think I understand what context is for, based on this from the NRL tutorial: ... 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:


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


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

Append child in oxygen still suggests quote in places where it doesn't belong though.

Posted: Thu Aug 09, 2007 2:02 pm
by george

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,