You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Lewis Denizen <sa...@ambisys.com> on 2004/06/18 06:58:17 UTC
Restriction within SimpleContent
Hi, I was checking out the schema tutorial from W3C
(http://www.w3schools.com/schema/schema_complex_text.asp). I came
across this definition, but Xerces doesn't seem to like it:
<xs:element name="somename">
<xs:complexType>
<xs:simpleContent>
<xs:restriction base="basetype">
....
....
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
</xs:element>
The error I receive back is:
Complex Type Definition Representation Error for type
'#AnonType_netnetssrcrulerulesfirewallconfig'. When <simpleContent> is
used, the base type must be a complexType whose content type is simple,
or, only if restriction is specified, a complex type with mixed content
and emptiable particle, or, only if extension is specified, a simple
type. 'string' satisfies none of these conditions.
Is this a Xerces error or is this non-standard XML Schema? Thanks in
advance!
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
RE: Restriction within SimpleContent
Posted by Lewis Denizen <sa...@ambisys.com>.
Hey George!
Thanks a million! It worked like a charm :) You saved me an entire
week of bashing my head against the wall ;)
Lewis
> -----Original Message-----
> From: George Cristian Bina [mailto:george@sync.ro]
> Sent: Friday, June 18, 2004 3:52 PM
> To: xerces-j-user@xml.apache.org
> Subject: Re: Restriction within SimpleContent
>
> Hi Lewis,
>
> > I'd really appreciate it if someone could show me
> > an example of how to get something like this covered with XML
Schema:
> > <nets>
> > <net prefix="24">192.168.0.0</net>
> > <net>192.168.1.4</net>
> > </nets>
>
> Define a simple type to restrict the string to the IPs and then extend
> it in the element definition to include the optional prefix attribute.
> Something like below should be close:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <xs:element name="nets">
> <xs:complexType>
> <xs:sequence>
> <xs:element maxOccurs="unbounded" ref="net"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> <xs:simpleType name="ip">
> <xs:restriction base="xs:string">
> <xs:pattern
>
value="[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-
9]
> ?[0-9]?"/>
> </xs:restriction>
> </xs:simpleType>
>
> <xs:element name="net">
> <xs:complexType>
> <xs:simpleContent>
> <xs:extension base="ip">
> <xs:attribute name="prefix" use="optional"
> type="xs:integer"/>
> </xs:extension>
> </xs:simpleContent>
> </xs:complexType>
> </xs:element>
> </xs:schema>
>
> Hope that helps,
> George
> -----------------------------------------------
> George Cristian Bina
> <oXygen/> XML Editor & XSLT Editor/Debugger
> http://www.oxygenxml.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Re: Restriction within SimpleContent
Posted by George Cristian Bina <ge...@sync.ro>.
Hi Lewis,
> I'd really appreciate it if someone could show me
> an example of how to get something like this covered with XML Schema:
> <nets>
> <net prefix="24">192.168.0.0</net>
> <net>192.168.1.4</net>
> </nets>
Define a simple type to restrict the string to the IPs and then extend
it in the element definition to include the optional prefix attribute.
Something like below should be close:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="nets">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="net"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="ip">
<xs:restriction base="xs:string">
<xs:pattern
value="[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9][0-9]?[0-9]?"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="net">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="ip">
<xs:attribute name="prefix" use="optional"
type="xs:integer"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>
Hope that helps,
George
-----------------------------------------------
George Cristian Bina
<oXygen/> XML Editor & XSLT Editor/Debugger
http://www.oxygenxml.com
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
RE: Restriction within SimpleContent
Posted by Lewis Denizen <sa...@ambisys.com>.
OK, after reading the error message a little more carefully, I think I
understand what the problem is, but don't know how to solve it. This is
the schema I have:
<xsd:element name="net" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType mixed="true">
<xsd:simpleContent>
<xsd:restriction base="xsd:string">
<xsd:pattern value="[0-9]"/>
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>
Basically, Xerces dislikes the "<xsd:restriction base="xsd:string">"
portion of the schema (I think). So, it wants me do something like...
<xsd:restriction base="xsd:complexType">, but that doesn't seem to work
either. Since it wants "a complex type with mixed content and emptiable
particle," this type has to have mixed content and an emptiable particle
(whatever that is). I'd really appreciate it if someone could show me
an example of how to get something like this covered with XML Schema:
<nets>
<net prefix="24">192.168.0.0</net>
<net>192.168.1.4</net>
</nets>
Thanks :)
> -----Original Message-----
> From: Lewis Denizen [mailto:sakai@ambisys.com]
> Sent: Friday, June 18, 2004 1:58 PM
> To: xerces-j-user@xml.apache.org
> Subject: Restriction within SimpleContent
>
> Hi, I was checking out the schema tutorial from W3C
> (http://www.w3schools.com/schema/schema_complex_text.asp). I came
> across this definition, but Xerces doesn't seem to like it:
>
> <xs:element name="somename">
> <xs:complexType>
> <xs:simpleContent>
> <xs:restriction base="basetype">
> ....
> ....
> </xs:restriction>
> </xs:simpleContent>
> </xs:complexType>
> </xs:element>
>
> The error I receive back is:
>
> Complex Type Definition Representation Error for type
> '#AnonType_netnetssrcrulerulesfirewallconfig'. When <simpleContent>
is
> used, the base type must be a complexType whose content type is
simple,
> or, only if restriction is specified, a complex type with mixed
content
> and emptiable particle, or, only if extension is specified, a simple
> type. 'string' satisfies none of these conditions.
>
> Is this a Xerces error or is this non-standard XML Schema? Thanks in
> advance!
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org