Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: XML schema question

From: "Stan Kitsis [MSFT]" <skits@---------.--->
To: NULL
Date: 4/6/2006 12:02:00 PM

John,

You can't enforse this using Xml Schema.  However, if both elements are 
required and the attributes, in both cases, are required and fixed, why do 
you need the attributes?  If you have a business reason to require those 
attributes, does the order matter?  You can create a global type that allows 
both values ("data" and "tra1") and require two reference elements in the 
sequence and then use a uniqueness constraint (xs:unique) to make sure that 
URI attributes are unique.  Alternatively you can rename the elements to 
something like reference-data and reference-tra1.

-- 
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights. 
Use of included script samples are subject to the terms specified at 
http://www.microsoft.com/info/cpyright.htm

"John Smith" <john.smith@m...> wrote in message 
news:g83Zf.1507$oj5.597142@n......
>
> Can you suggest me some solution? I was thinking that it is enough for XML 
> parser to differ elements by its position: first and second.
>
> Thank you.
>
>
>
> "swapna guddanti [MSFT]" <swapnag@m...> wrote in message 
> news:443402ea$1@n......
>> hi,
>> you cannot have two elements with the same name in the same scope that
>> differ only in attributes.
>> Reason:
>> A content model must be formed such that during validation of an element,
>> the items inside it can be uniqhely determined without examining the 
>> content
>> or attributes of that item.
>>
>> hope this helps,
>> swapna
>>
>>
>> "John Smith" <john.smith@m...> wrote in message
>> news:z1LYf.1475$oj5.582887@n......
>>>
>>> I have created a schema, but I got an error validating it. Is it 
>>> possible
>> to
>>> have 2 ds:Reference elements (with different attributes)?
>>>
>>> Error message:
>>>
>>> Element "ds:Reference" occurs more than once in the same content model 
>>> but
>>> does not refer to top-level type definition.
>>>
>>> Schema:
>>>
>>> <schema xmlns="http://www.w3.org/2001/XMLSchema"
>>> xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
>>> targetNamespace="http://www.w3.org/2000/09/xmldsig#"
>>> elementFormDefault="qualified" version="0.1">
>>> <!-- Basic Types Defined for Signatures -->
>>> <simpleType name="CryptoBinary">
>>> <restriction base="base64Binary"/>
>>> </simpleType>
>>> <!-- Start Signature -->
>>> <element name="Signature" type="ds:SignatureType"/>
>>> <complexType name="SignatureType">
>>> <sequence>
>>> <element ref="ds:SignedInfo"/>
>>> <element ref="ds:SignatureValue"/>
>>> <element ref="ds:KeyInfo"/>
>>> </sequence>
>>> <attribute name="Id" type="string" use="required" fixed="sig1"/>
>>> </complexType>
>>> <element name="SignatureValue" type="ds:SignatureValueType"/>
>>> <complexType name="SignatureValueType">
>>> <simpleContent>
>>> <extension base="base64Binary">
>>> <attribute name="Id" type="ID" use="optional"/>
>>> </extension>
>>> </simpleContent>
>>> </complexType>
>>> <!-- Start SignedInfo -->
>>> <element name="SignedInfo" type="ds:SignedInfoType"/>
>>> <complexType name="SignedInfoType">
>>> <sequence>
>>> <element ref="ds:CanonicalizationMethod"/>
>>> <element ref="ds:SignatureMethod"/>
>>> <element name="Reference">
>>> <complexType>
>>> <sequence>
>>> <element ref="ds:DigestMethod"/>
>>> <element ref="ds:DigestValue"/>
>>> </sequence>
>>> <attribute name="URI" type="anyURI" use="required" fixed="#data1"/>
>>> </complexType>
>>> </element>
>>> <element name="Reference">
>>> <complexType>
>>> <sequence>
>>> <element ref="ds:DigestMethod"/>
>>> <element ref="ds:DigestValue"/>
>>> </sequence>
>>> <attribute name="URI" type="anyURI" use="required" fixed="#tra1"/>
>>> </complexType>
>>> </element>
>>> </sequence>
>>> <attribute name="Id" type="ID" use="optional"/>
>>> </complexType>
>>> <element name="CanonicalizationMethod"
>>> type="ds:CanonicalizationMethodType"/>
>>> <complexType name="CanonicalizationMethodType" mixed="true">
>>> <attribute name="Algorithm" type="anyURI" use="required"/>
>>> </complexType>
>>> <element name="SignatureMethod" type="ds:SignatureMethodType"/>
>>> <complexType name="SignatureMethodType" mixed="true">
>>> <attribute name="Algorithm" type="anyURI" use="required"/>
>>> </complexType>
>>> <element name="DigestMethod" type="ds:DigestMethodType"/>
>>> <complexType name="DigestMethodType" mixed="true">
>>> <attribute name="Algorithm" type="anyURI" use="required"/>
>>> </complexType>
>>> <element name="DigestValue" type="ds:DigestValueType"/>
>>> <simpleType name="DigestValueType">
>>> <restriction base="base64Binary"/>
>>> </simpleType>
>>> <!-- End SignedInfo -->
>>> <!-- Start KeyInfo -->
>>> <element name="KeyInfo" type="ds:KeyInfoType"/>
>>> <complexType name="KeyInfoType" mixed="true">
>>> <choice>
>>> <element ref="ds:X509Data"/>
>>> </choice>
>>> <attribute name="Id" type="ID" use="optional"/>
>>> </complexType>
>>> <!-- Start X509Data -->
>>> <element name="X509Data" type="ds:X509DataType"/>
>>> <complexType name="X509DataType">
>>> <sequence>
>>> <choice>
>>> <element name="X509Certificate" type="base64Binary"/>
>>> </choice>
>>> </sequence>
>>> </complexType>
>>> <!-- End X509Data -->
>>> <!-- End KeyInfo -->
>>> <!-- End Signature -->
>>> </schema>
>>>
>>>
>>
>>
>
> 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent