Mythul
Mythul

Reputation: 1807

How to get the URL that loads the XSL page?

I'm a beginner with XSL. I need to use it with Java. The problem is I do not know how to get the value of the url that loads that XSL.

ex: www.mypage.com/resource.json

<table>
    <tr>
        <td>Content</td>
        <td> <xsl:value-of select="@content" /> </td>
    </tr>
</table>

What I want in the end is that the URL contains .json then display different information, for example if the URL contains .xml

Upvotes: 0

Views: 332

Answers (1)

kjhughes
kjhughes

Reputation: 111686

In XSLT 1.0, use xsl:param to pass the URI of the XSL or current document.

In XSLT 2.0, the XSLT file URI can be obtained via:

base-uri(document(''))

In XSLT 2.0, the current document URI can be obtained via:

base-uri()

Note: URIs do not necessarily exist for the XSLT or input XML because it's possible that these reside only in memory without being associated with a file.

Upvotes: 2

Related Questions