Re: [xsl] document-uri in MSXML

Subject: Re: [xsl] document-uri in MSXML
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 10 Jun 2016 20:02:43 -0000
On 10.06.2016 20:43, Mandar Jagtap jagman.tech@xxxxxxxxx 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.


Current Thread