Package com.sun.msv.reader.trex.typed


package com.sun.msv.reader.trex.typed

reads TREX grammar with "label annotation".

"label annotation" is a proprietary extension to TREX by MSV.

How it works

With this extension, <element> pattern in TREX pattern can have "label" attribute in http://www.sun.com/xml/msv/trex-type namespace.

<grammar xmlns:ext="http://www.sun.com/xml/msv/trex-type">
<start>
<element name="root" ext:label="root">
<choice>
<element name="child1"><empty /></element>
<element name="child2" ext:label="foo"><empty /></element>
</choice>
</element>
</start>
</grammar>

Once label is specified to <element> pattern, application can call Verifier.getCurrentElementType method to obtain a reference to TypedElementPattern object, which has label field.

void startElement( ... ) {
Object o = verifier.getCurrentElementType();
if(!( o instanceof TypedElementPattern ))
... // the current element does not have 'label' attribute.
else {
String labelOfTheCurrentElement = ((TypedElementPattern)o).label;
... // do whatever useful
}
}