cannot 'seek' inside a function
Hi,
i have the following : Blocks contain properties and can be nested. There is a tag called BlockParameterDefaults that contain default properties for each Block
<BlockParameterDefaults>
à à <Block>
<property name="BlockType" value="Gain" />
<property name="gain" value="1.00" />
à à </Block>
à à <Block>
<property name="BlockType" value="Sum" />
<property name="Inputs" value="2" />
à à </Block>
à à à ...
</BlockParameterDefaults>
and then :
à à <Block>
<property name="BlockType" value="Gain" />
<property name="Name" value="my_Gain" />
à à </Block>
what i want to do is to lookup for some property inside a Block, and when it is not found, get its value from BlockParameterDefaults. I know how to do that and i wrote a function :
<!-- lookup for a property and returns its value. If the property is not found in the current block, try to look for it in the <BlockParameterDefaults> under /Model
-->
à Ã
à à <xsl:function name="mdl2sig:lookup_property">
<xsl:param name="block_node" />
<xsl:param name="property_name" />
<xsl:choose>
à à <xsl:when test="$block_node[property[@name=$property_name]]">
<xsl:value-of select="$block_node/property[@name=$property_name]/@value" />
à à </xsl:when>
à à <xsl:otherwise>
<xsl:value-of select="/*[position()=1]/BlockParameterDefaults/Block[property[@name='BlockType' and @value=$block_node/property[@name='BlockType']]/@value]/property[@name=$property_name]/@value" />
à à </xsl:otherwise>
</xsl:choose>
à à </xsl:function>
but the processor tells : XPDY0002: Cannot select a node here: the context item is undefined
(it refers to the otherwise clause).
It seems logical because functions don't have contexts, but here i'm selecting a node with an absolute path, it should work, shoulnd't it ?
<BlockParameterDefaults> is always located under /Model or /Library
'/' = root
Thanks
|