On 15.08.2016 17:46, Mailing Lists Mail daktapaal(_at_)gmail(_dot_)com wrote:
1. How do we get the global Xpaths.. That can be used else where.
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
In my understand you have two options, one might be to use an
accumulator to store the value of the other element, the other would be
to use `copy-of()` on a common parent or ancestor and then work with
that copy with normal template.
Both solutions depend of course on the structure of the input and the
relation of those two elements, I am not sure where in your tree the
Amphibian are located in relation to the WaterSpeciesDisplayIndicator
element(s).
And of course the copy-of would pull a subtree into memory so is only
useful in the context of streaming for closely related elements like
siblings e.g.
<foo>
<bar>bar</bar>
<baz>baz</bar>
</foo>
with e.g.
<xsl:template match="foo">
<xsl:apply-templates select="copy-of()" mode="m2"/>
</xsl:template>
<xsl:template match="foo[bar = 'bar']/baz">
...
</xsl:template>
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--