Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] XSL: Transform links and sources to an absolute URL

From: "G. Ken Holman" <gkholman@-------------------->
To:
Date: 3/4/2009 12:51:00 PM
At 2009-03-04 13:35 +0100, Plew wrote:
Hello



this is my first post here, so i hope somebody can help me?
I have an XML file like this, with relative and absolute URL`s

<images>

   <img src="http://www.foo.de/test/bar.jpg" alt="" width="800" 
height="600" />

   <img src="/test/bar.jpg" alt="" width="800" height="600" />

</images>

<links>

   <a href="www.foo.de">...hi there</a>

   <a href="/test/test.html">bar</a>

</links>



..and know I need a way to append the absolute URL

Which absolute URL?  The ones from the image elements that are 
absolute, or the absolute URI of the XML file itself?



to the relative path`s to prevent errors, when i`m generating HTML 
on my server with an xslt.

Whats the best way? Pass a parameter with the URL to the XSLT?

Yes, if that is different than the absolute URI of the file itself.



For any given node you in the source tree can get the absolute URI of 
the source base document in XSLT 2 using:



  document-uri( root(  $node )  )



How can I dynamically add this to an src or href?

  resolve-uri( $relative-uri, $base-uri )



I hope this helps.



. . . . . . . . . . . Ken



--
XQuery/XSLT training in Prague, CZ 2009-03 http://www.xmlprague.cz
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent