Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A problem to make an XSD validator for an XML Signature

Status
Not open for further replies.

danube

Technical User
Jan 18, 2008
1
ES
I need to make a XSD File that validate another XML file with a digital signature. The code of the signature in the XML File is this (is not necessary to read all the code to answer my question):

Code:
<ds:Signature xmlns:ds="[URL unfurl="true"]http://www.w3.org/2000/09/xmldsig#">[/URL]
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="[URL unfurl="true"]http://www.w3.org/TR/2001/REC-xml-c14n-20010315"></ds:CanonicalizationMethod>[/URL]
<ds:SignatureMethod Algorithm="[URL unfurl="true"]http://www.w3.org/2000/09/xmldsig#rsa-sha1"></ds:SignatureMethod>[/URL]
<ds:Reference URI="">
<ds:Transforms>
<ds:Transform Algorithm="[URL unfurl="true"]http://www.w3.org/2000/09/xmldsig#enveloped-signature">[/URL]
</ds:Transform>
<ds:Transform Algorithm="[URL unfurl="true"]http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"></ds:Transform>[/URL]
</ds:Transforms>
<ds:DigestMethod Algorithm="[URL unfurl="true"]http://www.w3.org/2000/09/xmldsig#sha1"></ds:DigestMethod>[/URL]
<ds:DigestValue>text</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>text</ds:SignatureValue>
<ds:KeyInfo>
<ds:X509Data>
<ds:X509Certificate>text</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
</ds:Signature>


My question is very easy: I can´t use in the schema expresións like ” <element name=”ds: Signature>”, and I´ve found in Internet a lot f expressions like this:

<element name=”Signature” type=”ds:Signaure/>
…………………..............

What expresión can I use in my schema to correspond an XML expression like “<ds:Signature…>”???
 
[0] In your schema, you script the structure of your own namespace. As for element ds:Signature, you do not script it directly - you don't need to. You simply import it.

[1] At the schema root, add the xmlns declaration of the ds as the prefix for the xmldsig namespace.
[tt]
[ignore]xmlns:ds="[/ignore]
[/tt]
[2] Add the top-level xs:import element.
[tt]
[ignore]<xs:import namespace=" schemaLocation=" />[/ignore]
[/tt]
[2.1] Or you can save a copy of the schema to your local file system and refer the schemaLocation to it. (That would speed the validation up.)

[3] As to the element, you just use the reference at its place(s), like this.
[tt]
[ignore]<xs:element ref="ds:Signature" />[/ignore]
[/tt]
Then you're basically done.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top