|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: XSL:Copy w/ Processing Optimization Suggestions
> Here's what I'm currently doing:
> XSL:
> <?xml version="1.0"?>
> <xsl:stylesheet version="1.0" xmlns:xsl
> ="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml" />
>
> <xsl:template match="/">
> <xsl:apply-templates />
> </xsl:template>
>
> <xsl:template match="*|@*|processing-instruction()|text()">
> <!-- This seems to be the worst part. I'm doing string
> comarisons on the node name on every node in the tree.
> That's gotta be bad... -->
> <xsl:if test="not(name()='Part') or
> (contains(@DisplayValue,'BM5125') )">
> <xsl:copy>
> <xsl:apply-templates
> select="*|@*|processing-instruction()|text()">
> <xsl:sort order="ascending" select="@DisplayValue" />
> </xsl:apply-templates>
> </xsl:copy>
> </xsl:if>
> </xsl:template>
Firstly, you can use copy-of rather than apply-templates to process the
attributes.
You can use a direct nametest rather than a string comparison on the
name, and if your data is to be believed, you can use starts-with rather
than contains. You can also use template rules rather than xsl:if to
distinguish the two kinds of processing to be performed
<xsl:template match="*">
<xsl:copy-of select="@*"/>
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="Part[not(starts-with(@DisplayValue,
'BM5125'))]"/>
Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx
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








