开发者

XSL variable to lower case

开发者 https://www.devze.com 2023-02-05 19:31 出处:网络
I have an XML feed data that I need to make into a link using XSL v1.0... this works, but the TYPE value needs to be in lower case for the link to work properly:

I have an XML feed data that I need to make into a link using XSL v1.0... this works, but the TYPE value needs to be in lower case for the link to work properly:

<a href="http://www.mysite.com/{TYPE}={ID}" target="_blank">
  <img src="{IMAGE}" />
</a>

So, I tried doing this but it's giving me errors and I'm finding it difficult to trouble shoot as the error comes back as "开发者_开发技巧XSLT compile error at (1,991). See InnerException for details." (the below is just a snippet).

<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />

<xsl:element name="a">
  <xsl:attribute name="href">
    <xsl:value-of select="concat('http://www.mysite.com/', translate(TYPE, $uppercase, $smallcase),'=',ID)"/>
  </xsl:attribute>
  <xsl:attribute name="target">
    <xsl:text>_blank</xsl:text>
  </xsl:attribute>
  <xsl:text><img src="{IMAGE}" /></xsl:text>
</xsl:element>

Is there some blatantly obvious error there that I'm missing? Or maybe an easier method?


Much cleaner:

<a href="http://www.mysite.com/{translate(
                                   TYPE,
                                   $uppercase,
                                   $smallcase)}={ID}"
   target="_blank">
   <img src="{IMAGE}" />
</a> 


<xsl:text><img src="{IMAGE}" /></xsl:text>

should just be

<img src="{IMAGE}" />
0

精彩评论

暂无评论...
验证码 换一张
取 消