NSXMLDocument objectByApplyingXSLT with XSL Include

I'm having trouble with XSL processing when there are style sheets that contain other style sheets relatively.

(XML files may not be relevant, but included for completeness - the code is at the bottom).

Given an XML file:

<?xml version="1.0" ?>
<famous-persons>
<persons category="medicine">
  <person>
   <firstname> Edward   </firstname>
   <name>      Jenner   </name>
  </person>
</persons>
</famous-persons>

and XSL file:

<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
  <xsl:include href="included.xsl" />
</xsl:stylesheet>

referring to this stylesheet in the same directory as included.xsl:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0"> 
  <xsl:template match="/">
     <html><head><title>Sorting example</title></head><body>
    </body></html>
  </xsl:template>
</xsl:stylesheet>

how can I make the following code snippet:

NSError *lError = nil;
NSXMLDocument *lDocument = [ [ NSXMLDocument alloc ] initWithContentsOfURL:
                                        [ NSURL URLWithString: @"file:///pathto/data.xml" ]
                                    options: 0
                                    error: &lError ];

NSXMLDocument *lResult = [ lDocument objectByApplyingXSLTAtURL: [ NSURL URLWithString: @"file:///pathto/style.xsl" ]
                                    arguments: nil
                                    error: nil ];

doesn't give me an error:

I/O warning : failed to load external entity "included.xsl"
compilation error: element include
xsl:include : unable to load included.xsl

I tried all kinds of options. Also, loading XML documents with NSXMLDocumentXInclude does not help in advance. Specifying the absolute path to the attached XSL file works flawlessly.

Is there a way to do XSL processing so that the stylesheet can include another stylesheet in its local path?

+3
1

. SWXSLTransform, SWXMLMapping: https://github.com/oriontransfer/SWXMLMapping

, -[NSXMLDocument objectByApplyingXSLTAtURL:...] URL- libxslt. , URL-, libxslt URI. - URI - <xsl:include href="...">, href ... !

, NSXMLDocument , , , . .

+1

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


All Articles