1

For some reason, base-uri() is not returning the uri of the source file when I run an XSLT (using XSLT2, Saxon 9.4 PE).

Here is my xslt test case

<xsl:stylesheet version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"
xmlns:err="http://www.w3.org/2005/xqt-errors"
exclude-result-prefixes="xs xdt err fn">

<xsl:output method="xml" indent="yes"/>

<xsl:template match="/">

<xsl:value-of select="base-uri()"></xsl:value-of>
</xsl:template>

When I run this on a source xml file, I just get

<?xml version="1.0" encoding="UTF-8"?>

Note that I am able to retrieve the stylesheet URI just fine using base-uri(document('')).

I have also had no success using document-uri(/) either.

UPDATE: looks like there is definitely something amiss. It seems that nothing I do gets the processor to look in the SOURCE directory.

When I try "document('Dummy.xml',.) , it says it cannot find "Dummy.xml" even though that is the name of the source file.

Maybe I should re-install the jar file or email EditiX support.

4

1 回答 1

1

您如何从命令行或在您自己的代码中使用 Saxon?您如何向 Saxon 提供输入文档?当我从命令行(例如java -jar saxon9.he input.xml sheet.xsl)运行 Saxon 9.4 HE Java 时,我得到了一些有意义的输出(例如<?xml version="1.0" encoding="UTF-8"?>file:/C:/Users/UserName/Documents/xslt/input.xml)。

于 2012-03-27T13:48:03.793 回答