I am inserting two variables countryVar and langVar into a node in my xml document.
<link><![CDATA[/<% = countryVar %>/<% = langVar %>/products/index.aspx]]></link>
I am utilizing the link node in a xslt like this.
<a href="{link}"><xsl:value-of select="linkName"/></a>
The value of link prints out exactly like it is in the xml document. Is there any开发者_开发知识库 way to get the two vb.net variables countryVar and langVar to process and print out there value? The values are stored in cache and are pulled into the page.
Thanks
XSLT doesn't know anything about the variables in the (VB.NET) program that initiated the transformation.
There are two different ways to pass values of variables to the transformation:
Pass them as global parameters to the transformation. Read more how to do this together with
XslCompiledTransform.Transform()
:::: here.Modify the source XML document (after loading it, to contain the values of the variables in certain nodes.
I recommend method 1. above.
UPDATE:
Obviously you are using a variation of method 2. above. In this case it is not a good idea at all to put the values of the variables inside the same string.
Much better than:
<link><![CDATA[/<% = countryVar %>/<% = langVar %>/products/index.aspx]]></link>
(and it would be straightforward to process with XSLT afterwards, is:
<link>
<country><% = countryVar %></country>
<slash>/</slash>
<lang><% = langVar %></lang>
<tail-link>/products/index.aspx</tail-link>
<linkName>Whatever link text</linkName>
</link>
Then the XSLT code that processes this will be just:
<a href="{link}"><xsl:value-of select="linkName"/></a>
(this assumes that you have <xsl:strip-space elements="*"/>
at the global level in your stylesheet).
and the values of the variables are:
link/country
and
link/lang
精彩评论