[relaxng-user] Embedding HTML in a document: 'foreign-nodes' versus
namespaces
Nicholas Hemley
Nicholas.Hemley at lhb.scot.nhs.uk
Wed Nov 24 10:18:09 ICT 2004
Hello,
I am trying to allow HTML content within nodes of documents used in a
Java/XML application and have therefore used a 'foreign-nodes'
declaration in a Relax NG schema which is then converted to XML Schema
(since the app server only uses XML Schema) using the Jing utility:
Relax NG Schema [snippet]
...
define name="element-choice">
<element name="choice">
<zeroOrMore>
<ref name="element-choice-title"/>
</zeroOrMore>
<zeroOrMore>
--> here is the usage: <ref name="foreign-nodes"/>
</zeroOrMore>
</element>
</define>
...
<define name="foreign-elements">
<zeroOrMore>
<element>
<anyName/>
<ref name="anything"/>
</element>
</zeroOrMore>
</define>
<define name="anything">
<zeroOrMore>
<choice>
<element>
<anyName/>
<ref name="anything"/>
</element>
<attribute>
<anyName/>
</attribute>
<text/>
</choice>
</zeroOrMore>
</define>
<define name="foreign-attributes">
<zeroOrMore>
<attribute>
<anyName/>
</attribute>
</zeroOrMore>
</define>
<define name="foreign-nodes">
<zeroOrMore>
<choice>
<text/>
<ref name="foreign-attributes"/>
<ref name="foreign-elements"/>
</choice>
</zeroOrMore>
</define>
And here is a snippet of the generated XML Schema:
XML Schema [snippet - generated]
...
<xs:group name="foreign-elements">
<xs:sequence>
<xs:any minOccurs="0" maxOccurs="unbounded"
processContents="skip"/>
</xs:sequence>
</xs:group>
<xs:group name="anything">
<xs:sequence>
<xs:any minOccurs="0" maxOccurs="unbounded"
processContents="skip"/>
</xs:sequence>
</xs:group>
<xs:attributeGroup name="anything">
<xs:anyAttribute processContents="skip"/>
</xs:attributeGroup>
<xs:attributeGroup name="foreign-attributes">
<xs:anyAttribute processContents="skip"/>
</xs:attributeGroup>
<xs:group name="foreign-nodes">
<xs:sequence>
<xs:group minOccurs="0" maxOccurs="unbounded"
ref="foreign-elements"/>
</xs:sequence>
</xs:group>
<xs:attributeGroup name="foreign-nodes">
<xs:attributeGroup ref="foreign-attributes"/>
</xs:attributeGroup>
...
Firstly, is this schema correct? Could someone explain why it has
created a group and attributeGroup with the same name?
When I try and view the XML through my application I get the following
error reported:
Root cause follows.
com.sun.msv.verifier.jarv.FactoryImpl$WrapperException: reference to
the undefined attribute group: "foreign-attributes"
My question is therefore this: is the problem with how Jing has
converted the schema or my initial schema?
My other question is this: can I use namespaces instead of a
'foreign-nodes' declaration to achieve the same aim?
Fire those knowledge arrows at me!
Cheerio,
Nic.
Nic Hemley
Lothian NHS Webmaster & Developer
internal: 89240
external: 0131 536 9240
int'l: +00 44 131 536 9240
web: www.nhslothian.scot.nhs.uk
**********************************************************************
The information contained in this message may be confidential or legally privileged and is intended for the addressee only, If you have received this message in error or there are any problems please notify the originator immediately. The unauthorised use, disclosure, copying or alteration of this message is strictly forbidden.
**********************************************************************
More information about the relaxng-user
mailing list