|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: sorting and merging
Riboni Ugo wrote:
>
> hi everybody,
> i'm new ot this list but maybe someone can can give me some help
> to solve this problem i have.
>
Welcome.
This is a nice problem to demonstrate the advantages of "push" style
xslt programming, where the flow of control is determined by the
structure of the data being transformed, not directly by the transform.
It's a bit like event driven programming, and makes it very easy to do
things like saying "pass everything straight through unless it's an
'x'".
I copied your fragment file directly, and just tidied up your main file
a bit. The transform is nice and simple.
Hope this helps -
Francis.
C:\xml>type t.xml
<?xml version="1.0" encoding="UTF-8"?>
<ex>
<qs>
<q type="S">
<as>
<a>txt</a>
</as>
</q>
</qs>
</ex>
C:\xml>type t.xslt
<?xml version="1.0"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output indent="yes"/>
<!-- the identity transform - passes anything straight through ... -->
<xsl:template match="@*|node()[not(self::as)]" >
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- -->
<!-- ... except for "as" elements - a specific match has a higher
priority -->
<xsl:template match="as">
<xsl:for-each select="document('new-vals.xml')/temproot/a">
<xsl:sort select="@new" data-type="number"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:template>
<!-- -->
</xsl:transform>
C:\xml>saxon t.xml t.xslt
<?xml version="1.0" encoding="utf-8"?>
<ex>
<qs>
<q type="S">
<a new="1">txt</a>
<a new="2">txt</a>
<a new="3">txt</a>
</q>
</qs>
</ex>
C:\xml>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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








