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

XSL:Copy w/ Processing Optimization Suggestions

Subject: XSL:Copy w/ Processing Optimization Suggestions
From: "DANA CORDES" <dcordes@xxxxxxxx>
Date: Wed, 12 Mar 2003 17:26:01 -0800
dana cordes
I need to convert an XML tree into a similiar tree, with some processing
performed on a subset of the data.  The full XML document is being rendered
via XSL into HTML for web display, and I have a section that contains what
will be converted into a data table.

I'm performing preprocess filtering and sorting functions through the XSL,
and I'm having memory consuption issues, so I'm trying to find an optimal
way of doing this.  I'm looking for any pointers on a better/faster/more
effecient way of doing this.

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>
</xsl:stylesheet>


Input XML:
<?xml version="1.0" encoding="utf-8"?>
<CatalogPartSpecsList>
  <Globals/>
  <Nav>
    <Catalog access="true" />
    <Login access="true" />
  </Nav>

  <Body>
    <Results>
      <Part DisplayValue="BM6015-04W-B50"/>
      <Part DisplayValue="BM5125-04W-B50"/>
      <Part DisplayValue="BM5125-04W-B40"/>
      <Part DisplayValue="BM5125-04W-B30"/>
      <Part DisplayValue="BM5115-04W-B50"/>
    </Results>
  </Body>
</CatalogPartSpecsList>

Desired XML Output:
<?xml version="1.0" encoding="utf-8"?>
<CatalogPartSpecsList>
  <Globals/>
  <Nav>
    <Catalog access="true" />
    <Login access="true" />
  </Nav>

  <Body>
    <Results>
      <Part DisplayValue="BM5125-04W-B30"/>
      <Part DisplayValue="BM5125-04W-B40"/>
      <Part DisplayValue="BM5125-04W-B50"/>
    </Results>
  </Body>
</CatalogPartSpecsList>

So, basically this all works, but I'm sure there is a much more effecient
way of doing it.  Could anyone give me some input on optimization?


Dana Cordes
Senior Programmer/Analyst
Information Technologies
New Hampshire Ball Bearing, Chatsworth
dcordes@xxxxxxxx


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.