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

Re: Effecient element "filtering" technique recommenda

Subject: Re: Effecient element "filtering" technique recommendations.
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Mon, 07 Oct 2002 22:03:55 +0200
j element
Edward L. Knoll wrote:
We have some XML which effectively represents the contents of a table. Each row from the table is an element; each column in a row is a
subelement within the row. The XML we generate for the table could
contain more columns than we actually want to process/display.


I have another element which identifies all of the columns to be
processed/displayed. The subelements of this element have the same
names as the row columns.


I'm looking for recommendations on ways in which we can only process the
row columns which correspond to the other columns.
...
XSL (fragments) w/ filtering::

<xsl:variable name="TableColumns" select="/Table/Columns/*" />

<xsl:template  select="/Table/Row">
   <xsl:for-each select="*">
      <xsl:variable name="MyName" select="name()" />
      <xsl:if test="$TableColumns[name()=$MyName]" >
         <xsl:apply-templates select="." mode="ColumnContent" />
      </xsl:if>
Instead of selecting all elements and filtering out later, select
only the elements you want. Also, using a key might speed it up:
 <xsl:key name="cols" match="/Table/Columns/*" use="name()"/>
 <xsl:template  select="/Table/Row">
    <xsl:for-each select="*[key('cols',name())]">

I also suggest to try other XML designs, like
<Table>
  <Columns>
    <Column>1</Column>
    ...
  </Columns>

  <Row>
    <Column id="1">...</Column>
    ...

J.Pietschmann


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.