Previous | Next | Indexes
adultinternetusers > Tutorials > XSLT 2.0 Tutorial > Functions operating on strings (13/15) >

Absolute URIs' from relative ones with resolve-uri() function

The function resolve-uri() resolves a relative URI provided as the first argument on the basis of URI provided as the second argument. If the relative URI is an empty sequence an empty sequence is returned, if the base URI is empty, a fatal error occurs.

This function does not attempt to find out whether the URI exists, it is merely a syntactic operation on two character strings.

Please note the difference between baseA and baseB. If we imagine that the base URI addresses a filesystem, the CCC in baseA is a directory, in baseB a file.

XSLT

      <xsl:stylesheet
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="2.0">
            <xsl:output  method="xml"
                        indent="yes"
                        omit-xml-declaration="yes"/>

            <xsl:template  match="/aaa">
                  <xxx>
                        <i>
                              <xsl:value-of  select="resolve-uri(bbb,baseA)"/>
                        </i>
                        <ii>
                              <xsl:value-of  select="resolve-uri(bbb,baseB)"/>
                        </ii>
                  </xxx>
                  <yyy>
                        <i>
                              <xsl:value-of  select="resolve-uri(ccc,baseA)"/>
                        </i>
                        <ii>
                              <xsl:value-of  select="resolve-uri(ccc,baseB)"/>
                        </ii>
                  </yyy>
                  <zzz>
                        <i>
                              <xsl:value-of  select="resolve-uri(ddd,baseA)"/>
                        </i>
                        <ii>
                              <xsl:value-of  select="resolve-uri(ddd,baseB)"/>
                        </ii>
                  </zzz>
                  <ppp>
                        <i>
                              <xsl:value-of  select="resolve-uri(eee,baseA)"/>
                        </i>
                        <ii>
                              <xsl:value-of  select="resolve-uri(eee,baseB)"/>
                        </ii>
                  </ppp>
                  <qqq>
                        <i>
                              <xsl:value-of  select="resolve-uri(fff,baseA)"/>
                        </i>
                        <ii>
                              <xsl:value-of  select="resolve-uri(fff,baseB)"/>
                        </ii>
                  </qqq>
                  <rrr>
                        <i>
                              <xsl:value-of  select="resolve-uri(ggg,baseA)"/>
                        </i>
                        <ii>
                              <xsl:value-of  select="resolve-uri(ggg,baseB)"/>
                        </ii>
                  </rrr>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa>
            <baseA>http://adultinternetusers.com/AAA/BBB/CCC/</baseA>
            <baseB>http://adultinternetusers.com/AAA/BBB/CCC</baseB>
            <bbb>bbb.xml</bbb>
            <ccc>../../CCC/ccc.xml</ccc>
            <ddd>../..</ddd>
            <eee>/eee.xml</eee>
            <fff>../../../../../../../</fff>
      </aaa>
Output

      <xxx>
            <i>http://adultinternetusers.com/AAA/BBB/CCC/bbb.xml</i>
            <ii>http://adultinternetusers.com/AAA/BBB/bbb.xml</ii>
      </xxx>
      <yyy>
            <i>http://adultinternetusers.com/AAA/CCC/ccc.xml</i>
            <ii>http://adultinternetusers.com/CCC/ccc.xml</ii>
      </yyy>
      <zzz>
            <i>http://adultinternetusers.com/AAA/</i>
            <ii>http://adultinternetusers.com/</ii>
      </zzz>
      <ppp>
            <i>http://adultinternetusers.com/eee.xml</i>
            <ii>http://adultinternetusers.com/eee.xml</ii>
      </ppp>
      <qqq>
            <i>http://adultinternetusers.com/../../../../</i>
            <ii>http://adultinternetusers.com/../../../../../</ii>
      </qqq>
      <rrr>
            <i/>
            <ii/>
      </rrr>


Previous chapter: Arithmetics
Next chapter: Transforming strings with regular expressions
Previous page: Joining strings with string-join
Next page: Escaping of URI with encode-for-uri, iri-to-uri, and escape-html-uri

Kevin Carr in Stanton

Natural Skin Care and European Soaps
TickTalk 5
city of stanton
internetusers


You can also get Organic Skin Care products from Bliss Bath Body and you must check out their Natural Body Lotions and bath soaps

Now if you are looking for the best deals on surf clothing from Quiksilver and Roxy then you have to check these amazing deals here:

Hey, check out this Organic Skin Care European Soaps along with Natural Lavender Body Lotion and shea butter

and we can get surf t shirts surfing shirt and And you must check out this website swim suit swimming suit and swim trunks