In the Java XML transformation package, there is a concept known as a URIResolver, which is "An object that implements this interface that can be called by the processor to turn a URI used in document(), xsl:import, or xsl:include into a Source object."
So, if your XSL has an import like this
<xsl:import href="URI"/>
This allows you to take URI and map it to the Source of your choice - maybe it comes from a database, or maybe you want to map the URI to another URI. This can be useful, since you can't use an xsl:variable
in the xsl:import href
.
Here is some sample Java code that creates a transformer and does a transform.
URIResolver uriResolver = new MyURIResolver(); // sample
TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setURIResolver(uriResolver);
Transformer transformer = transformerFactory.newTransformer();
transformer.setURIResolver(uriResolver);
transformer.transform(xml, result);
Note, there are two places in the code where the URIResolver is used:
- TransformerFactory setURIResolver - "Set an object that is used by default during the transformation to resolve URIs used in document(), xsl:import, or xsl:include."
- Transformer setURIResolver - "Set an object that will be used to resolve URIs used in document()."
Question: Is there a similar concept to the Java URIResolver in C# and .NET?