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

Re: Global Variables in streaming xslts

Subject: Re: Global Variables in streaming xslts
From: "Mailing Lists Mail daktapaal@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 15 Aug 2016 16:58:33 -0000
Re:  Global Variables in streaming xslts
Thanks Martin and Michael.
My conditions can be quite randomly picking nodes from trees .. so i am
going to try using the parse multiple times to populate these variables
technique...
Thanks again. A lot of learning again for me..

On Aug 15, 2016 12:46 PM, "Michael Kay mike@xxxxxxxxxxxx" <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

>
> On 15 Aug 2016, at 16:46, Mailing Lists Mail daktapaal@xxxxxxxxx <
> xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Dear All..
> I have some.more questions
>
> 1. How do we get the global Xpaths.. That can be used else where.
>
>
> Basically, you can't. The code you provide isn't streamable.
>
> There may be workarounds. For example, you could process the input stream
> twice, once to extract the "lookup" information, and once to process the
> data that references it. Then you might write:
>
> <xsl:variable name="WaterSpeciesDisplayIndicator" as="xs:boolean">
>   <xsl:stream href="UniverseKingdom.xml">
>     <xsl:select="/*:UniverseKingdom/*:DisplayIndicators/*:WaterSpeciesDisplayIndicator
> = 'true'"/>
>   </xsl:stream>
> </xsl:variable>
>
> Note that (in Saxon at any rate) this will stop processing the input
> stream as soon as a qualifying element is found, so it may not be as
> expensive as processing the whole document twice.
>
> If the lookup data is at the start of the file, and always appears before
> you need it, then another approach is to use accumulators. These read data
> "in the background" as the input stream is being read:
>
> <xsl:accumulator name="indicator" as="xs:boolean" initial-value="false()">
>   <xsl:accumulator-rule match="/*:UniverseKingdom/*:DisplayIndicators/*:
> WaterSpeciesDisplayIndicator/text()[. = 'true']"
>      select="true()"/>
> </xsl:accumulator>
>
> which you can then reference as <xsl:if test="accumulator-before('
> indicator')">....
>
> Michael Kay
> Saxonica
>
>
> select="/*:UniverseKingdom/*:DisplayIndicators/*:WaterSpeciesDisplayIndicator
> = 'true'"/>
>
>   example: I want to know somewhere in some template the value of some
> other element : for example  In Amphibian template definition, I want to
> know if  WaterSpeciesDisplayIndicator is set to true :
>
>  Code:
>
>   <xsl:transform version="3.0" xmlns:xsl="http://www.w3.org/
> 1999/XSL/Transform" xmlns:saxon="http://saxon.sf.net/" xmlns:multiclass="
> http://www.csp.com/Securitization/csp-multiclass" xmlns:mismo="
> http://www.mismo.org/residential/2009/schemas">
>
>             <xsl:mode name="stream" streamable="yes"
> on-no-match="shallow-copy"/>
>
>             <xsl:output method="xml" indent="yes"/>
>
>            <xsl:variable name="WaterSpeciesDisplayIndicator"
> select="/*:UniverseKingdom/*:DisplayIndicators/*:WaterSpeciesDisplayIndicator
> = 'true'"/>
>
>
>             <xsl:template match="/">
>
>    <xsl:stream href="UniverseKingdom.xml">
>
>          <xsl:apply-templates mode="stream"/>
>                         </xsl:stream>
>             </xsl:template>
>
>
>
>             <xsl:template match="*:Amphibian">
>
>  <xsl:if test = "$WaterSpeciesDisplayIndicator"> <xsl:copy-of select =
> "."/>
> </xsl:if>
>
>             </xsl:template>
>
>             I know that GLobal parameters will not work because the
> variables probably doesnt know the XML we are streaming at the time of
> declaration. I also know that from the template match for Amphibian, I can
> not get to the xpath of /*:UniverseKingdom/*:DisplayIndicators/*:
> WaterSpeciesDisplayIndicator.
>
>            I am not sure how else I should be getting the
> WaterSpeciesDisplayIndicator Value
>
> Thanks
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://-list/293509> (by email)
>
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <-list/1311928> (by
> email <>)

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.