Subject: Re: [xsl] 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 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Ways to Identify & Process Sa, Alex S as.signup@xxx | Thread | Re: [xsl] Ways to Identify & Proces, Wendell Piez wapiez@ |
[xsl] Ways to Identify & Process Sa, Alex S as.signup@xxx | Date | Re: [xsl] Ways to Identify & Proces, Wendell Piez wapiez@ |
Month |