[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Hi,
You could possibly simply add a template like
<xsl:template match="o[@t='Info']">
<xsl:element name="{@t}">
<xsl:apply-templates select="a[(@n!='Info') and (@n!='Sender')]"/>
<xsl:apply-templates select="a[(@n='Info') or (@n='Sender')]"/>
</xsl:element>
</xsl:template>
which would ensure that attributes are processed first.
But I can not see where the </Header> in your output comes from.
Re: [xsl] Some attribute not displayed in output
Subject: Re: [xsl] Some attribute not displayed in output From: ac <ac@xxxxxxxxxxxxx> Date: Wed, 26 Aug 2009 23:45:09 -0400 |
Hi,
You could possibly simply add a template like
<xsl:template match="o[@t='Info']">
<xsl:element name="{@t}">
<xsl:apply-templates select="a[(@n!='Info') and (@n!='Sender')]"/>
<xsl:apply-templates select="a[(@n='Info') or (@n='Sender')]"/>
</xsl:element>
</xsl:template>
which would ensure that attributes are processed first.
But I can not see where the </Header> in your output comes from.
Cheers, ac
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>
Current Thread |
---|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Some attribute not displayed , lee qm | Thread | Re: [xsl] Some attribute not displa, lee qm |
[xsl] Some attribute not displayed , lee qm | Date | [xsl] IE does not comprehend defaul, denit thomas |
Month |
Keywords