G
Geathaa
Hi everyone,
I want to transform a xml document containing the description of a
menu tree to HTML. The MenuTree XML contains the target URL for each
tree node. Some URL's contain parameters which are only known at
runtime though. These "runtime parameters" are also set as global
parameters in the XSLT stylesheet. What I want to do now is check the
URL defined in the XML and replace any "runtime parameter" with the
stylesheet parameter of the same name. Parameters which should be
replaced are enclosed in curly brackets (If there is any better way to
do this please let me know...)
The following example should clear things up:
---The XML---
<MenuTree>
<TreeNode>
<NodeId>1</NodeId>
<ParentNode>0</ParentNode>
<Label>ObjectData</Label>
<Action>objectdata.html?sessionid={sessionid}</Action>
<Target>OBJ_DATA_MAIN</Target>
<Active>true</Active>
<Icon></Icon>
<IconOpen></IconOpen>
</TreeNode>
</MenuTree>
---The XSLT stylesheet ---
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslutput method="html"/>
<!-- Global Parameter: Sessionid provided at runtime -->
<xslaram name="sessionid"/>
....
<xsl:apply-templates select="/MenuTree/TreeNode/Action"/>
....
---Desired Output ----
Let's assume that the sessionid was "1234" when calling the
transformation. The XSLT stylesheet's global parameter $sessionid is
set to "1234" and the transformation of the node
"/MenuTree/TreeNode/Action" should produce the following string as the
menu node's URL:
objectdata.html?sessionid=1234
Thamks for your help! Greetings, Geathaa
I want to transform a xml document containing the description of a
menu tree to HTML. The MenuTree XML contains the target URL for each
tree node. Some URL's contain parameters which are only known at
runtime though. These "runtime parameters" are also set as global
parameters in the XSLT stylesheet. What I want to do now is check the
URL defined in the XML and replace any "runtime parameter" with the
stylesheet parameter of the same name. Parameters which should be
replaced are enclosed in curly brackets (If there is any better way to
do this please let me know...)
The following example should clear things up:
---The XML---
<MenuTree>
<TreeNode>
<NodeId>1</NodeId>
<ParentNode>0</ParentNode>
<Label>ObjectData</Label>
<Action>objectdata.html?sessionid={sessionid}</Action>
<Target>OBJ_DATA_MAIN</Target>
<Active>true</Active>
<Icon></Icon>
<IconOpen></IconOpen>
</TreeNode>
</MenuTree>
---The XSLT stylesheet ---
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslutput method="html"/>
<!-- Global Parameter: Sessionid provided at runtime -->
<xslaram name="sessionid"/>
....
<xsl:apply-templates select="/MenuTree/TreeNode/Action"/>
....
---Desired Output ----
Let's assume that the sessionid was "1234" when calling the
transformation. The XSLT stylesheet's global parameter $sessionid is
set to "1234" and the transformation of the node
"/MenuTree/TreeNode/Action" should produce the following string as the
menu node's URL:
objectdata.html?sessionid=1234
Thamks for your help! Greetings, Geathaa