Using the document () function in .NET XSLT generates an error

I would like to use the embedded resources in my XSLT file, but when calling 'document (...)' C # complains that "Error loading document ..."

I would like to use certain resources in the XSLT file and get them as follows: "document ('') // my: resources /" ...

How can i do this?

ex xsl:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:my="xslt-gruper-v1.2.xsl" exclude-result-prefixes="my">

     <my:resources>
      <one>tryb</one>
     </my:resources>

     <xsl:variable name="res" select="document('')/*/my:resources/("/>
</xsl:stylesheet>

How can I access such a structure without exceptions in C #? I will add that during static conversion through ex. Opera everything is working fine.

+3
source share
1 answer
<xsl:variable name="res" select="document('')/*/my:resources/("/>

select XPath. XSLT- .

:

<xsl:variable name="vRes" select="document('')/*/my:resources"/>

, XsltSettings.

XsltSettings , :

XsltSettings(true, false)

- false.

:

// Create the XsltSettings object with document() enabled and script disabled.
XsltSettings settings = new XsltSettings(true,false);

// Create the XslCompiledTransform object and load the style sheet.
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load("sort.xsl", settings, new XmlUrlResolver());

. , XSLT ( ). XSLT- uri document('').

, xsl:variable xxx:node-set() .

+10

Source: https://habr.com/ru/post/1742720/


All Articles