|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: preceding-sibling:: while keeping xml well formed
Try something like:
<xsl:template match="b//i | i//b">
<bolditalic>
<xsl:apply-templates/>
</bolditalic>
</xsl:template>
In your example the b is an ancestor or descendant of the i, not a sibling.
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: Spencer Tickner [mailto:spencertickner@xxxxxxxxx]
> Sent: 31 May 2005 17:48
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: preceding-sibling:: while keeping xml well formed
>
> 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
|
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
|

Cart








