xsl-list
[Top] [All Lists]

preceding-sibling:: while keeping xml well formed

2005-05-31 09:47:59
Hello, and thanks in advance for the help.

I am using xslt to convert one xml to another importable xml.
Everything is going fine except for the fact that the program I am
importing into supports <italic>, and <bold>, but needs a <bolditalic>
when the both are together.

My original xml file is used on the web so of course 

<i>This<b>is</b>valid</i>.

I assume this can be done using the preceding-sibiling axis to achive
something along the lines of

<italic>This</italic><bolditalic>is</boldItalic><italic>valid</italic>

So far I'm just hitting templates with my inline elements, However I
still just get <bold> and <italic> tags with the xsl below:


XML

<document>
  <test>This <b>is a <i>test</i> of bolditalic</b> type</test>
</document>

XSLT

<xsl:template match="document">
        <xsl:apply-templates select="test"/>
</xsl:template>

<xsl:template match="test">
        <xsl:element name="newxmltag">
                <xsl:applytemplates="text()|i|b"/>
        </xsl:element>
</xsl:template>

<xsl:template match="b">
<xsl:choose>
        <xsl:when test="preceding-sibling::strong">
                <xsl:element name="bolditalic">
                        <xsl:apply-templates/>
                </xsl:element>
        </xsl:when>
        <xsl:otherwise>
                <xsl:element name="bold">
                        <xsl:apply-templates/>
                </xsl:element>
        </xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template match="i">
<xsl:choose>
        <xsl:when test="preceding-sibling::strong">
                <xsl:element name="bolditalic">
                        <xsl:apply-templates/>
                </xsl:element>
        </xsl:when>
        <xsl:otherwise>
                <xsl:element name="italic">
                        <xsl:apply-templates/>
                </xsl:element>
        </xsl:otherwise>
</xsl:choose>
</xsl:template>



Any Help you all can offer would be very appreciated.

Thank you,

Spencer

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>