NSXMLDocument objectByApplyingXSLT with XSL Include
NSXMLDocument objectByApplyingXSLT with XSL Include
- Subject: NSXMLDocument objectByApplyingXSLT with XSL Include
- From: Kristof Van Landschoot <email@hidden>
- Date: Mon, 19 Apr 2010 22:11:08 +0200
Hi all,
I'm having some trouble with XSL-processing when there are stylesheets that
include other stylesheets relatively.
(the XML-files may be irrelevant but are included for completeness - code is
at the bottom).
Given the XML-file:
<?xml version="1.0" ?>
<famous-persons>
<persons category="medicine">
<person>
<firstname> Edward </firstname>
<name> Jenner </name>
</person>
<person>
<firstname> Gertrude </firstname>
<name> Elion </name>
</person>
</persons>
</famous-persons>
and the XSL-file:
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xi="http://www.w3.org/2001/XInclude"
version="1.0">
<xsl:template match="/">
<html><head><title>Sorting example</title></head><body>
<xsl:apply-templates select="famous-persons/persons">
<xsl:sort select="@category" />
</xsl:apply-templates>
</body></html>
</xsl:template>
<xsl:include href="included.xsl" />
</xsl:stylesheet>
referencing this stylesheet in included.xsl:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xi="http://www.w3.org/2001/XInclude"
version="1.0">
<xsl:template match="persons">
<h2><xsl:value-of select="@category" /></h2>
<ul>Irrelevant</ul>
</xsl:template>
</xsl:stylesheet>
how can I make it that the following code fragment:
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 ];
does not give me the error:
*I/O warning : failed to load external entity "included.xsl"*
*compilation error: element include*
*xsl:include : unable to load included.xsl*
*
*
I have been trying all sorts of options. Also loading XML documents
with NSXMLDocumentXInclude
beforehand does not seem to help.
Is there any way to make the XSL processing so that a stylesheet can include
another stylesheet in its local path?
Thanks for your help,
Kristof
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden