|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: This could be simple, but not for me!
> -----Original Message----- > From: Kenny Bogoe (BogoeMD) [mailto:kenny@xxxxxxxxx] > Hi, > Though I have been working sometime with XSLT, I am having > trouble with this transformation. > Anyone know how to do this? > The XML source is from a database and is really really huge > in size, so performance of the transformation is very critical... > Not sure whether it can be optimized further, but it seems to yield the desired output... <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" indent="yes" encoding="ISO-8859-1" /> <!-- this key will return all cities having a Detail descendant with the supplied value for @no --> <xsl:key name="city-by-detail" match="City" use="following-sibling::A/B/Info/Detail/@no" /> <xsl:key name="detail-key" match="Detail" use="@no" /> <xsl:variable name="unique-details" select="//Detail[generate-id()=generate-id( key('detail-key',@no))]" /> <xsl:template match="/"> <xsl:apply-templates select="$unique-details" /> </xsl:template> <xsl:template match="Detail"> <xsl:value-of select="concat('
',@no,', ',.,'
')" /> <xsl:apply-templates select="key('city-by-detail',@no)"> <xsl:with-param name="pNo" select="@no" /> </xsl:apply-templates> </xsl:template> <xsl:template match="City"> <xsl:param name="pNo" /> <xsl:apply-templates select="following-sibling::A/B/Name[ following::Info[1]/Detail/@no=$pNo]" /> </xsl:template> <xsl:template match="Name"> <xsl:if test="position()=1"> <xsl:value-of select="concat('
	', ancestor::Community/City)" /> </xsl:if> <xsl:value-of select="concat('
		',.)" /> </xsl:template> </xsl:stylesheet> Hope this helps! Greetz, Andreas
|
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








