Re: [xsl] retaining entity declarations while converting from one xml format to another

Subject: Re: [xsl] retaining entity declarations while converting from one xml format to another
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 16 Dec 2009 00:53:12 GMT
> I am sorry I forgot to mention one piece of information here. These
> input files were originally SGML and were then converted to well

but assuming spoon.jpg is a jpeg file, the same would apply in SGML as
well, image entities should be NDATA (not parsed) and referenced as
attribute values, not using &  ; notation.

> So when I do the <xsl:copy> the entities are not copied over.

parsed entities (referenced by &) are expanded by the XML parser before
XSLT even sees the input. So XSLT can not copy them as it never sees

But you can not reference a jpg file that way.

An NDATA entity is referenced as attribute value typically
something like

<!ENTITY spoon.jpg SYSTEM "spoon.jpg" NDATA jpg>

 <image ref="spoon.jpg"/>

if you access the entity this way, then the attribute value is available
to xslt and you can look up the SYSTEM URI using unparsed-entity-uri().

But you showed a parsed entity declaration

<!ENTITY spoon.jpg SYSTEM "spoon.jpg" >

which would be acceessed by

& s p o o n . j p g ;

such a reference would be expanded by the xml parser before xslt sees
the data (and generate a fatal error if it is a jpeg file rather than

As you haven't shown how you are referencing the entities in the source
file I can't really guess what to suggest.


The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 

Current Thread