I have XSLT transforming my XML Spreadsheet. Works well except for one part.
On the worksheet my cells would look like this:
HeadingName1
bike1 True
bike2 False
HeadingName2
Car1 True
Car2 False
Car3 True
The XSL looks like this:
What comes out from that is:
What I want is not to output any element with an id=""
Is that possible as we only know if the attribute is "" after we draw out the element tag???
Therefore the desired output would be
note: I relised after that I had 4 attributes... I'm thinking of changing the element to
<element type="mode" name="bike" id="1" selected="1"/>
On the worksheet my cells would look like this:
HeadingName1
bike1 True
bike2 False
HeadingName2
Car1 True
Car2 False
Car3 True
The XSL looks like this:
Code:
<xsl:for-each select="ss:Table/ss:Row">
<!-- Get the Element attributes then add if necessary -->
<xsl:element name="element">
<xsl:for-each select="ss:Cell">
<xsl:choose>
<xsl:when test="position()=1">
<xsl:attribute name="type">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:when>
<xsl:when test="position()=2">
<xsl:attribute name="name">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:when>
<xsl:when test="position()=3">
<xsl:attribute name="id">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="selected">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
What comes out from that is:
Code:
<ApplicableToTabWorksheet>
<element name="HeadingName1" id="" selected=""/>
<element name="Car1" id="1" selected="1"/>
<element name="Car2" id="2" selected=""/>
<element name=""/>
<element name="HeadingName2" id="" selected="Selected"/>
<element name="car1" id="1" selected="1"/>
<element name="car2" id="2" selected=""/>
<element name="car3" id="3" selected="1"/>
</ApplicableToTabWorksheet
What I want is not to output any element with an id=""
Is that possible as we only know if the attribute is "" after we draw out the element tag???
Therefore the desired output would be
Code:
<ApplicableToTabWorksheet>
<element name="bike1" id="1" selected="1"/>
<element name="bike2" id="2" selected=""/>
<element name="car1" id="1" selected="1"/>
<element name="car2" id="2" selected=""/>
<element name="car3" id="3" selected="1"/>
</ApplicableToTabWorksheet
note: I relised after that I had 4 attributes... I'm thinking of changing the element to
<element type="mode" name="bike" id="1" selected="1"/>