[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

preceding-sibling:: while keeping xml well formed

Subject: preceding-sibling:: while keeping xml well formed
From: Spencer Tickner <spencertickner@xxxxxxxxx>
Date: Tue, 31 May 2005 09:47:59 -0700
preceding sibling in xslt
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.