[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Hi,
You can iterate the elements with lower case names and sort selecting the corresponding upper case element:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<result>
<xsl:for-each select="*/*[translate(name(), 'ABCDE', 'abcde') = name()]">
<xsl:sort select="../*[name() = translate(name(current()), 'abcde', 'ABCDE')]"/>
<no><xsl:value-of select="."/></no>
</xsl:for-each>
</result>
</xsl:template>
</xsl:stylesheet>
Kenny Bogoe (BogoeMD) wrote:
Re: [xsl] Sorting and replacing content
Subject: Re: [xsl] Sorting and replacing content From: George Cristian Bina <george@xxxxxxx> Date: Wed, 01 Sep 2004 12:55:02 +0300 |
Hi,
You can iterate the elements with lower case names and sort selecting the corresponding upper case element:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<result>
<xsl:for-each select="*/*[translate(name(), 'ABCDE', 'abcde') = name()]">
<xsl:sort select="../*[name() = translate(name(current()), 'abcde', 'ABCDE')]"/>
<no><xsl:value-of select="."/></no>
</xsl:for-each>
</result>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?> <result><no>30</no><no>40</no><no>10</no><no>50</no><no>20</no></result>
Best Regards, George ----------------------------------------------- George Cristian Bina <oXygen/> XML Editor & XSLT Editor/Debugger http://www.oxygenxml.com
Kenny Bogoe (BogoeMD) wrote:
Hi,
I have this structure where the content of tags <A> to <E> have to determine the order of tag-content <a> to <e>. The result needs to be as shown below.
I can manage to make a stylesheet with an <xsl:if> for each <A> to <E> asking whether the number is 1, 2, 3, 4 or 5, but I am sure there must be a simpler way to do this. I can not use position() since the position af the tags can change in the structure.
<Root> <a>10</a> <b>20</b> <c>30</c> <d>40</d> <e>50</e> ...
... <A>3</A> <B>5</B> <C>1</C> <D>2</D> <E>4</E> </Root>
Result I need:
<no>30</no> <!-- C = 1 has to be first with the value of c (which is 30) --> <no>40</no> <no>10</no> <no>50</no> <no>30</no>
Thanks. Kenny Bogoe
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Sorting and replacing con, David Carlisle | Thread | Re: [xsl] Sorting and replacing con, Kenny Bogoe (BogoeMD |
RE: [xsl] Sorting and replacing con, Andrew Welch | Date | RE: [xsl] Performance problems with, Michael Kay |
Month |
Keywords