|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Some attribute not displayed in output
I had following src xml file which needs to convert to the output.xml
given below.
I found some of the attributes ("MissingAttribute" in example given
below) is not written to the output.xml with the stylesheet given.
I check the spec and found that adding attribute after child node is
added is illegal.
Can someone help me on how to modify the stylesheet to get the
expected output (where "MissingAttribute" appeared as a attribute of
Header element)?
src.xml (simplied version, the actual src files had many 'a' element)
-----------
<?xml version="1.0" encoding="UTF-8"?>
<data>
<o t="request">
<a n="Info">
<o t="Info">
<a n="TimeStamp">
<v s="2009-08-81 12:59:59"/>
</a>
<a n="Sender">
<o t="Sender">
<a n="Login">
<v s="username"/>
</a>
</o>
</a>
<a n="MissingAttribute">
<v s="xxx"/>
</a>
</o>
</a>
</o>
</data>
output.xml
----------------
<?xml version="1.0" encoding="utf-8"?>
<request>
<Info TimeStamp="2009-08-81 12:59:59" MissingAttribute="xxx">
<Sender Login="username"/>
</Header>
</request>
Stylesheet
----------------
<xsl:template match="o">
<xsl:element name="{@t}">
<xsl:apply-templates select="a"/>
</xsl:element>
</xsl:template>
<xsl:template match="a">
<xsl:if test="(@n!='Info') and (@n!='Sender') ">
<xsl:attribute name="{@n}">
<xsl:for-each select="v">
<xsl:value-of select="@s"/>
</xsl:for-each>
</xsl:attribute>
</xsl:if>
<xsl:if test="(@n='Info') or (@n='Sender') ">
<xsl:apply-templates select="o"/>
</xsl:if>
</xsl:template>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






