i want to transform xml file yusuf.xml collapsing all elements like suraid,verseid etc except <yusuf> as attributes:
Code:
<ahmed>
<suraid>1</suraid>
<verseid>3</verseid>
<groupcode>1.2-4</groupcode>
<yusuf>Most Gracious, Most Merciful;</yusuf>
</ahmed>
<ahmed>
<suraid>1</suraid>
<verseid>4</verseid>
<groupcode>1.2-4</groupcode>
<yusuf>Master of the Day of Judgment.</yusuf>
</ahmed>
above code should look like
Code:
<quran suraid="1" verseid="3" groupcode="1.2-4" author="yusuf">
Most Gracious, Most Merciful;
</quran>
<quran suraid="1" verseid="4" groupcode="1.2-4" author="yusuf">
Master of the Day of Judgment;
</quran>
see to it that i want the verse contents in the <quran> tag
below is my schema xsd for above ,its not giving the desired result :
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2011 rel. 2 (x64) (http://www.altova.com) by aliabbas (puu) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="quran">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="verseid" type="xs:unsignedShort"/>
<xs:attribute name="suraid" type="xs:unsignedByte" use="required"/>
<xs:attribute name="groupcode" type="xs:string"/>
<xs:attribute name="author" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>
following is the transformation xsl file
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="var1_dataroot" select="dataroot"/>
<quran>
<xsl:attribute name="xsi:noNamespaceSchemaLocation" namespace="http://www.w3.org/2001/XMLSchema-instance">C:/Users/ALI/Documents/transform.xsd</xsl:attribute>
<xsl:for-each select="$var1_dataroot/ahmed/verseid">
<xsl:attribute name="verseid">
<xsl:value-of select="string(floor(number(string(.))))"/>
</xsl:attribute>
</xsl:for-each>
<xsl:for-each select="$var1_dataroot/ahmed/suraid">
<xsl:attribute name="suraid">
<xsl:value-of select="string(floor(number(string(.))))"/>
</xsl:attribute>
</xsl:for-each>
<xsl:for-each select="$var1_dataroot/ahmed/groupcode">
<xsl:attribute name="groupcode">
<xsl:value-of select="string(.)"/>
</xsl:attribute>
</xsl:for-each>
</quran>
</xsl:template>
</xsl:stylesheet>
i used mapforce but i cant get the contents of each verse in individual <quran> tag
and i am getting only one <quran > instance as output
please help me