Jump to content

replace function problems


javajoemorgan
 Share

Recommended Posts

I have a small piece of xml that contains a reference to an image, and the reference needs to be changed. I suspect the replace function is good for that. Here's the actual code snippet that tries to create the anchor to the image derived from the GRAPHICFILEPATH attribute of a nested GRAPHIC element:

<a class="clsGraphicLink" href="{replace(GRAPHIC/@GRAPHICFILEPATH, 'aaaa.bbbb.com', 'xxxx.yyyy.com/extImage')}" target="_blank">	   Fig. <xsl:number format="1" level="any"/>: <xsl:value-of select="CAPTION"/></a>

The GRAPHICFILEPATH contains a direct link to the image, however, we can't have that in our resulting HTML page. We have to have it point back to us. So, if the actual GRAPHICFILEPATH = "http://aaaa.bbbb.com/images/BlueBonnet.jpg", it just needs to be output as "http://xxxx.yyyy.com/extImage/images/BlueBonnet.jpg". So, I "thought" the above replace function would work, but it is returning a blank.I am 1000% percent certain the value of GRAPHICFILEPATH contains the "aaaa.bbbb.com".... just why is the replace not working?I'm getting:

<a class="clsGraphicLink" href="" target="_blank">Fig whatever</a>

Link to comment
Share on other sites

Are you sure you have an XSLT 2.0 processor, and that you've declared 'version="2.0"' at the top of the stylesheet? The replace() function is only available in XSLT 2.0.

Link to comment
Share on other sites

Are you sure you have an XSLT 2.0 processor, and that you've declared 'version="2.0"' at the top of the stylesheet? The replace() function is only available in XSLT 2.0.
I do have 'version="2.0"' declared, and am fairly certain the processor is v2. Is there a poor man's way of finding out via the XSL. The device I'm using doesn't tell me directly.
Link to comment
Share on other sites

I do have 'version="2.0"' declared, and am fairly certain the processor is v2. Is there a poor man's way of finding out via the XSL. The device I'm using doesn't tell me directly.
<xsl:value-of select="system-property('xsl:version')"/>

will tell you what version of XSLT can your XSLT processor process. If it's at least SAXON 8 or AltovaXML2007 (and you know THAT for sure), there's no even need to do the system property part - those processors are known to support XSLT 2.0.

Link to comment
Share on other sites

<xsl:value-of select="system-property('xsl:version')"/>

will tell you what version of XSLT can your XSLT processor process. If it's at least SAXON 8 or AltovaXML2007 (and you know THAT for sure), there's no even need to do the system property part - those processors are known to support XSLT 2.0.

OK...cool and not so cool! It plainly returned version 1.What options do I have?
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...