posted 16 years ago
Hi All
Initially i am using a.xsd file(Schema) for a project which takes an input file (.xml) file from a location and read the entire file and then a .xslt(transformation purpose) is used to transform the input xml file in a desired fashion (which is compatible with the .xsd file against which the outcomming .xml file from .xslt , is validated , so it's running fine but what happen there is some changes done in the schema(.xsd file) (and no changes in the inpuit .xml file)
so what we have to do , we have to change in the .xslt file so that it will change the outcomming .xml file compatible to .xsd(new one) file for validation to be sussessfully.
for the old .xsd and .xslt files everything is running fine but according to the .xsd file i have changes the .xslt file but at run time the validation fails and the error is : "Validation against XML schema failed"
sample file is :
1) old .xsd file :
<?xml version="1.0" encoding="UTF-8"?>
<!-- ============================================================================= -->
<!-- VMS to Vcommerce catalog schema -->
<!-- v 6/22/2007 -->
<!-- ============================================================================= -->
<!-- Revision History -->
<!-- 4/23: added minOccurs="0" to all second-level collection tags including <genre>, <actor>, <director> -->
<!-- <writer>, <producer>, <image-reference>, <video-reference> -->
<!-- 6/8: renamed <genres> to <studio-genres>. added <amg-genres>. added <asset-type> -->
<!-- 6/11: moved <amg-genres> under new <discovery> tag, removed <amg-did> tag from <studio-genres>, -->
<!--collapsed <studio-genres><genre><description> to <studio-genres><genre> -->
<!-- 6/22: renamed <studio-genres> to <genres>, restructured <discovery> block a bit, created discovery-type -->
<!--renamed <mpaa-rating> to <rating> -->
<!-- ============================================================================= -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- ============================================================================= -->
<!-- discovery type -->
<!-- ============================================================================= -->
<xs:complexType name="discovery-type">
<xs:sequence>
<xs:element name="amg" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="genres" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="genre" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="description" type="xs:string"/>
<xs:element name="amg-did" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
and corresponding .xslt file is : (only relevant values i am giving)
<discovery>
<amg>
<genres>
<xsl:for-each select="amg-genres/genre">
<genre>
<description><xsl:value-of select="name" /></description>
<amg-did><xsl:value-of select="amg-did" /></amg-did>
</genre>
</xsl:for-each>
</genres>
</amg>
</discovery>
2) The new one .xsd file is :
<?xml version="1.0" encoding="UTF-8"?>
<!-- ============================================================================= -->
<!-- VMS to Vcommerce catalog schema -->
<!-- v 6/22/2007 -->
<!-- ============================================================================= -->
<!-- Revision History -->
<!-- 4/23: added minOccurs="0" to all second-level collection tags including <genre>, <actor>, <director> -->
<!-- <writer>, <producer>, <image-reference>, <video-reference> -->
<!-- 6/8: renamed <genres> to <studio-genres>. added <amg-genres>. added <asset-type> -->
<!-- 6/11: moved <amg-genres> under new <discovery> tag, removed <amg-did> tag from <studio-genres>, -->
<!--collapsed <studio-genres><genre><description> to <studio-genres><genre> -->
<!-- 6/22: renamed <studio-genres> to <genres>, restructured <discovery> block a bit, created discovery-type -->
<!--renamed <mpaa-rating> to <rating> -->
<!-- ============================================================================= -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<!-- ============================================================================= -->
<!-- discovery type -->
<!-- ============================================================================= -->
<xs:complexType name="discovery-type">
<xs:sequence>
<xs:element name="amg" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="genric" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="genres" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="genre" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="description" type="xs:string"/>
<xs:element name="amg-did" type="xs:string" minOccurs="0"/>
</xs:sequence>
and corresponding .xslt file is : (only relevant content is given)
<discovery>
<amg>
<genric>
<genres>
<xsl:for-each select="amg-genres/genre">
<genre>
<description><xsl:value-of select="name" /></description>
<amg-did><xsl:value-of select="amg-did" /></amg-did>
</genre>
</xsl:for-each>
</genres>
</genric>
</amg>
</discovery>
Note : there is only one tag changes in the .xsd file <genric> in between <amg> and <genres> ,
But at run time the validation fails against the Schema defined and in the output .xml file there is no <genric> tag included even though it has been included in the .xslt(new one) file.
Please do the needfull
Thanks In Advance
Divya