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: Fri, 18 Dec 2009 15:13:34 GMT
>  NDATA ccitt4">


As i said in my inital reply, I suspected that you were using NDATA
entities. Despite the fact that your example code did not use this form.

This completely changes the question  as while it's true that you lose
the declarations, you do not (unlike a normal parsed entity) lose the
entity references.

> I need to retain those in my intermediate output.

By far the simplest way, if you can control the source, is not to do this

<!DOCTYPE example[
<!ENTITY  t1 SYSTEM "image.tif" NDATA ccitt4">

but instead do this

<!DOCTYPE example SYSTEM "images.ent">

images.ent containing
<!ENTITY  t1 SYSTEM "image.tif" NDATA ccitt4">

then you can use <xsl:output doctype-system="images.ent"/> and the same
declaration is used for both input and output.

But if you really do need to dynamically detect which declarations are
usied in the source you need to either read the source as text  using
unparsed-text() and extract the DOCTYPE or use an extension function or
modified parser that passes on doctype information via some mechanism. The XDM model
used by XPath/XSLT to model the input document has no record of the
DOCTYPE used. Andrew's lexev might be able to do this, I coudn't tell
from the web page whether it reported entity declarations in teh local
subset  of the dtd or only reported teh public and system ids.


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