A
afc46220
Hello,
I am a novice with XSL, and can't quite figure out how to come up with
a solution for the following problem. Let's assume we have the
following set of XML nodes:
<DataBlocks>
<AlphaBlock>
<AlphaBlock.Name>Alpha<AlphaBlock.Name/>
<AlphaBlock.Value>1<Alpha.Block.Value/>
<AlphaBlock/>
<BetaBlock>
<BetaBlock.Name>Beta</BetaBlock.Name/>
<BetaBlock.Value>2<BetaBlock.Block.Value/>
<BetaBlock/>
<DataBlocks/>
Alpha and Beta blocks contain information that can be processed in
identical way, therefore I intend to utilize one template, something
like:
<xsl:template match="DataBlocks//AlphaBlock | DataBlocks//BetaBlock">
....
<xsl:template/>
Within that template, I want to create a variable, which would hold the
name of the node:
<xsl:variable name="BlockType">
<xsl:choose>
<xsl:when test = "contains(current(),
'BetaBlock')>BetaBlock</xsl:when>
<xsltherwise>AlphaBlock</xsltherwise>
</xsl:choose>
</xsl:variable>
My goal is then to use that variable to access both AlphaBlock.Value
and BetaBlock.Value nodes in something like:
Value is <xsl:value-of select="concat($BlockType,'.Value')"/>, but
certainly it does not work.
I would appreciate your help.
Thanks.
Alex.
I am a novice with XSL, and can't quite figure out how to come up with
a solution for the following problem. Let's assume we have the
following set of XML nodes:
<DataBlocks>
<AlphaBlock>
<AlphaBlock.Name>Alpha<AlphaBlock.Name/>
<AlphaBlock.Value>1<Alpha.Block.Value/>
<AlphaBlock/>
<BetaBlock>
<BetaBlock.Name>Beta</BetaBlock.Name/>
<BetaBlock.Value>2<BetaBlock.Block.Value/>
<BetaBlock/>
<DataBlocks/>
Alpha and Beta blocks contain information that can be processed in
identical way, therefore I intend to utilize one template, something
like:
<xsl:template match="DataBlocks//AlphaBlock | DataBlocks//BetaBlock">
....
<xsl:template/>
Within that template, I want to create a variable, which would hold the
name of the node:
<xsl:variable name="BlockType">
<xsl:choose>
<xsl:when test = "contains(current(),
'BetaBlock')>BetaBlock</xsl:when>
<xsltherwise>AlphaBlock</xsltherwise>
</xsl:choose>
</xsl:variable>
My goal is then to use that variable to access both AlphaBlock.Value
and BetaBlock.Value nodes in something like:
Value is <xsl:value-of select="concat($BlockType,'.Value')"/>, but
certainly it does not work.
I would appreciate your help.
Thanks.
Alex.