how to validate XML against one given xsd file

J

jacksuyu

For example the XML looks like:

<SOAP-ENV:Body>

<samlp:Response InResponseTo="abcd"
IssueInstant="2005-02-03T20:18:06Z" MajorVersion="1" MinorVersion="0"
ResponseID="abcd">

<samlp:Status>
<samlp:StatusCode Value="samlp:Success"/>
</samlp:Status>

<saml:Assertion AssertionID="12343" InResponseTo="1234"
IssueInstant="2005-02-03T20:18:06Z" Issuer="http://www.fmr.com"
MajorVersion="1" MinorVersion="0" id="id-gLxbrihSvyx3"
xsi:type="lib:AssertionType">

<saml:Conditions>

<saml:AudienceRestrictionCondition>
<saml:Audience>abcd</saml:Audience>
</saml:AudienceRestrictionCondition>
</saml:Conditions>




the XSD file is:



<?xml version="1.0" encoding="UTF-8" ?>
<schema targetNamespace="urn:eek:asis:names:tc:SAML:1.0:assertion"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:saml="urn:eek:asis:names:tc:SAML:1.0:assertion"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified" attributeFormDefault="unqualified"
version="1.1">
<import namespace="http://www.w3.org/2000/09/xmldsig#"
schemaLocation="http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd"
/>
<annotation>
<documentation>Document identifier:
oasis-sstc-saml-schema-assertion-1.1 Location:
http://www.oasis-open.org/committees/documents.php?wg_abbrev=security
Revision history: V1.0 (November, 2002): Initial standard schema. V1.1
(September, 2003): * Note that V1.1 of this schema has the same XML
namespace as V1.0. Rebased ID content directly on XML Schema types
Added DoNotCacheCondition element and
DoNotCacheConditionType</documentation>
</annotation>
<simpleType name="DecisionType">
<restriction base="string">
<enumeration value="Permit" />
<enumeration value="Deny" />
<enumeration value="Indeterminate" />
</restriction>
</simpleType>
<element name="AssertionIDReference" type="NCName" />
<element name="Assertion" type="saml:AssertionType" />
<complexType name="AssertionType">
 
F

Fabien R

For example the XML looks like:

<SOAP-ENV:Body>

<samlp:Response InResponseTo="abcd"
IssueInstant="2005-02-03T20:18:06Z" MajorVersion="1" MinorVersion="0"
ResponseID="abcd">

<samlp:Status>
<samlp:StatusCode Value="samlp:Success"/>
</samlp:Status>

<saml:Assertion AssertionID="12343" InResponseTo="1234"
IssueInstant="2005-02-03T20:18:06Z" Issuer="http://www.fmr.com"
MajorVersion="1" MinorVersion="0" id="id-gLxbrihSvyx3"
xsi:type="lib:AssertionType">

<saml:Conditions>

<saml:AudienceRestrictionCondition>
<saml:Audience>abcd</saml:Audience>
</saml:AudienceRestrictionCondition>
</saml:Conditions>




the XSD file is:



<?xml version="1.0" encoding="UTF-8" ?>
<schema targetNamespace="urn:eek:asis:names:tc:SAML:1.0:assertion"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:saml="urn:eek:asis:names:tc:SAML:1.0:assertion"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified" attributeFormDefault="unqualified"
version="1.1">
<import namespace="http://www.w3.org/2000/09/xmldsig#"
schemaLocation="http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd"
/>
<annotation>
<documentation>Document identifier:
oasis-sstc-saml-schema-assertion-1.1 Location:
http://www.oasis-open.org/committees/documents.php?wg_abbrev=security
Revision history: V1.0 (November, 2002): Initial standard schema. V1.1
(September, 2003): * Note that V1.1 of this schema has the same XML
namespace as V1.0. Rebased ID content directly on XML Schema types
Added DoNotCacheCondition element and
DoNotCacheConditionType</documentation>
</annotation>
<simpleType name="DecisionType">
<restriction base="string">
<enumeration value="Permit" />
<enumeration value="Deny" />
<enumeration value="Indeterminate" />
</restriction>
</simpleType>
<element name="AssertionIDReference" type="NCName" />
<element name="Assertion" type="saml:AssertionType" />
<complexType name="AssertionType">
On my linux platform, I use:
xmllint --schema <mySchema.xsd> <myXml.xml>

-
Fabien
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top