| 
 
Subject: [xsl] preceding-sibling:: while keeping xml well formed From: Spencer Tickner <spencertickner@xxxxxxxxx> Date: Tue, 31 May 2005 09:47:59 -0700  | 
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
| Current Thread | 
|---|
  | 
| <- Previous | Index | Next -> | 
|---|---|---|
| Re: [xsl] pre/post text, David Carlisle | Thread | RE: [xsl] preceding-sibling:: while, Michael Kay | 
| RE: [xsl] xsl:include problems, Hardy Merrill | Date | RE: [xsl] element to root, Michael Kay | 
| Month |