[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Newbie question: fixed attribute & restriction
- From: Priscilla Walmsley <priscilla@walmsley.com>
- To: 'Guy Crets' <guycrets@hotmail.com>, xml-dev@lists.xml.org
- Date: Fri, 10 Aug 2001 11:08:23 -0400
Hi Guy,
You can't add new attributes in a restriction. What you want is an
extension.
The only time you would use attributes in a restriction would be to restrict
attributes that are already declared for the base type. (e.g., to restrict
the attribute's type, to make an optional attribute required, etc.) This
would only apply if the base type was a complex type, though.
Priscilla Walmsley
Vitria Technology
> -----Original Message-----
> From: Guy Crets [mailto:guycrets@hotmail.com]
> Sent: Friday, August 10, 2001 10:27 AM
> To: xml-dev@lists.xml.org
> Subject: Newbie question: fixed attribute & restriction
>
>
> Hi All,
>
> Is it allowed to have an attribute within a restriction? If I
> read/understand the Schema 2001 spec well, it is.
>
> However, Xerces 1.4.2 reports an error when parsing (validating) the
> document underneath. "Error: URI=null Line=5: Schema error:
> Anonymous
> complexType: ct-props-correct.2: The type 'xsd:string' is a
> simple type. It
> cannot be used in a derivation by RESTRICTION for a
> complexType." When
> using extension instead of restriction, all goes well.
>
> Thanks for your feedback. Regards, Guy Crets (Belgium)
>
> xsd/ODS-ME-RA02-3.xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- test xsd - guycrets@hotmail.com - Guy Crets 08-aug-2001 -->
> <xsd:schema targetNamespace="http://www.test.com/ODS-ME-RA02-3"
> xmlns="http://www.test.com/ODS-ME-RA02-3"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified"
> version="8-aug-2001">
>
> <xsd:element name="RA02_StatementOfAccountMessage">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element ref="C022_InformationFromFunloc" minOccurs="1"
> maxOccurs="1"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
>
> <xsd:element name="C022_InformationFromFunloc">
> <xsd:complexType>
> <xsd:simpleContent>
> <xsd:restriction base="xsd:string">
> <xsd:attribute name="type" type="xsd:string" fixed="DE"/>
> </xsd:restriction>
> </xsd:simpleContent>
> </xsd:complexType>
> </xsd:element>
>
> </xsd:schema>
>
> RA02t3.xml:
> <?xml version="1.0" encoding="UTF-8"?>
> <RA02_StatementOfAccountMessage
> xmlns="http://www.test.com/ODS-ME-RA02-3"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.test.com/ODS-ME-RA02-3
> xsd/ODS-ME-RA02-3.xsd">
> <C022_InformationFromFunloc>134446</C022_InformationFromFunloc>
> </RA02_StatementOfAccountMessage>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at
> http://explorer.msn.com/intl.asp
>
>
> ------------------------------------------------------------------
> The xml-dev list is sponsored by XML.org
> <http://www.xml.org>, an initiative of OASIS
> <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To unsubscribe from this elist send a message with the single word
> "unsubscribe" in the body to: xml-dev-request@lists.xml.org
>