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

Re: Ways to Identify & Process Same name XML elements

Subject: Re: Ways to Identify & Process Same name XML elements differently based on location in XML tree?
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 25 Oct 2017 12:52:29 -0000
Re:  Ways to Identify & Process Same name XML elements
On Wed, Oct 25, 2017 at 12:34:55PM -0000, Alex S as.signup@xxxxxxxxxxx
scripsit:
>  Some elements such as: <string> <array> <dict> appear repeatedly at
>  multiple levels in this SB XML format, But they mean different things
>  based on where they are located; mean different things at different
>  locations, depths or parent/ ascendent
> 
>  What are the different ways I can tackle processing these elements
>  and fix & improve my <xsl templates>?

There's a general XSLT 2.0-and-greater pattern, "chained processing",
where you can put a document node in a variable so you can pass the
result of one processing pass to the next using variables:

<xsl:variable name="pass1">
    <xsl:apply-templates mode="preprocess"/>
</xsl:variable>
<xsl:apply-templates select="pass1"/>

This generalizes to arbitrarily many variables (presuming the documents
aren't large enough to give you memory issues at however many variables
you need) and I find it's a good way to keep different bits of the
processing logic distinct in the code and thus easier to debug.

So nothing wrong with doing what you're already doing and using a
pre-processing pass to give the elements distinct names depending on
position and then processing on that basis.

-- Graydon

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.