xsl-list
[Top] [All Lists]

Re: [xsl] document-uri in MSXML

2016-06-11 08:07:45
Thanks a lot Martin. It works well with your solution.
On 10 Jun 2016 10:02 pm, "Martin Honnen martin(_dot_)honnen(_at_)gmx(_dot_)de" <
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

On 10.06.2016 20:43, Mandar Jagtap jagman(_dot_)tech(_at_)gmail(_dot_)com 
wrote:

I have a limitation to use MSXML 3.0 only as a XSLT processor but I
want to get a URI or full path of source xml document that is being
processed. Using Saxon or using XSLT 2.0, I can get it using
document-uri(.). But, I don't seem to be able to find way to get it
with limited MSXML 3.0 functions.

Can somebody provide help on how to achieve it?


You could insert some VBScript or JScript and read out the "url" property
the MSXML DOM exposes:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
        xmlns:msxsl="urn:schemas-microsoft-com:xslt"
        xmlns:js="http://example.com/js";
        exclude-result-prefixes="msxsl js"
        version="1.0">

        <msxsl:script language="JScript" implements-prefix="js">
                function documentUri(nodeSet) {
                        var node = nodeSet.item(0);
                        return node.nodeType === 9 ? node.url :
node.ownerDocument.url;
                }
        </msxsl:script>

        <xsl:output indent="yes"/>

        <xsl:template match="/">
                <results>
                        <result>
                                <xsl:value-of select="js:documentUri(/)"/>
                        </result>
                        <result>
                                <xsl:value-of select="js:documentUri(/*)"/>
                        </result>
                </results>

        </xsl:template>
</xsl:stylesheet>


Note that in a quick test here I got a file URI returned for an input file
from the file system, only it had "_xml" appended at the end to the file
name.


--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>