Reputation: 11
I am in the process of converting some XSLT (more specifically schematron validation rules) from using Altova to Saxon.NET (Saxon-HE version="9.7.0.4") as the XSLT processor. However, I came to a problem which I cannot find a resolution for.
The problem is with the document() function. In my XSLT I have:
<sch:let name="params" value="document('https://some_web_address')"/>
This URL brings back an XML of parameters which the XSLT uses. The problem is that this works in Altova but does not work (returns empty) when I started using Saxon.NET
After trying doc-available()/unparsed-text-available() functions, it seems like none return true for the XML coming from the URL. However, if I create a xml file of the returned xml data, place it in the local directory (local to my XSLT) and specify the full path to the xslt, unparsed-text-available() function returns true, yet doc-available() still returns false. I even created a small dummy XML sample:
<?xml version="1.0" encoding="UTF-8"?>
<parameters>
<parameter>100</parameter>
</parameters>
The XML is valid, but came back with same exact results (doc-available() = false, unparsed-text-available() = true)
I have looked at some of the other related questions on here (XSLT Document() Function results in Saxon Error/ Attribute-String cant be used as Filepath) but none of them fully resolved my problem.
This issue might have to do something with the base URI of the XSLT sheet, so I run: base-uri(.) and static-base-uri() and both returned empty.
So my questions are:
The ideal solution for me would be to use the URL, but it can be downgraded to using a local file. I would appreciate if anyone can help me with this.
Upvotes: 1
Views: 655
Reputation: 11
Ok, after a really long research it turned out to be something really stupid on my part.
Issue was that in the code where we are using Saxon.NET we were setting:
xsltExecutable.InputXmlResolver = null
for some unknown reason. It should have been
xsltExecutable.InputXmlResolver = new XmlUrlResolver();
since XmlUrlResolver is what pulls the data from external sources.
I got to this when trying to setup a small schematron test case, which was working fine in the command line, but would not work in .NET app.
This post also helped: How to use the XSLT fn:document function in Saxon-HE to read an XML string?
Thanks guys
Upvotes: 0