Re: Problems converting <xs:any> schema elements
Bob Foster <[email protected]> Fri, 28 May 2004 02:10:35 -0500
| Newsgroups | gmane.text.xml.relaxng.general |
|---|---|
| Message-ID | <[email protected]> |
Let's say you have a schema like:
<xs:schema elementFormDefault="qualified" xml:lang="EN"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="foo">
<xs:element name="example">
<xs:complexType>
<xs:sequence>
<xs:any namespace="##other" processContents="lax"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The rough equivalent of the above written in the compact syntax would be:
default namespace foo = "foo"
start = element example { anybutfoo }
anybutfoo = element * - foo { anycontents }
anycontents = mixed {
(attribute * { text }
| any)*
}
any = element * { anycontents }
Trang translates this to RELAX NG as:
<?xml version="1.0" encoding="UTF-8"?>
<grammar ns="foo" xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<element name="example">
<ref name="anybutfoo"/>
</element>
</start>
<define name="anybutfoo">
<element>
<anyName>
<except>
<name>foo</name>
</except>
</anyName>
<ref name="anycontents"/>
</element>
</define>
<define name="anycontents">
<mixed>
<zeroOrMore>
<choice>
<attribute>
<anyName/>
</attribute>
<ref name="any"/>
</choice>
</zeroOrMore>
</mixed>
</define>
<define name="any">
<element>
<anyName/>
<ref name="anycontents"/>
</element>
</define>
</grammar>
Bob Foster
http://xmlbuddy.com/
Spencer Cheng wrote:
> Hi Folks,
>
> I am trying to convert some existing W3C XML schema from MPEG into
> relaxNG schema using Sun's RNG converter (mainly so I can edit XML
> documents using nXML). I am running into problems with the conversion of
> xs:any elements.
>
> The original elements typically looks like this.
>
> <xsd:any namespace="##other" processContents="lax"/>
>
> The output from rngconv looks like
>
> <define name="any(lax:##other)5">
>
> Which does not validate. Being new to relaxNG, would someone provide
> some hints on how to fix these manually? I could remove them from the
> original schema but that seems to be cheating. :)
>
> Regards
> Spencer
>
> _______________________________________________
> relaxng-user mailing list
> [email protected]
> http://relaxng.org/mailman/listinfo/relaxng-user
>