Re: [xsl] Preserving Graphic Entities

Subject: Re: [xsl] Preserving Graphic Entities
From: "Norm Tovey-Walsh ndw@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 14 Jul 2022 08:20:52 -0000
"rick@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> writes:
> The output will just be some basic transforms that wonbt affect the
> graphics. I am using Saxon EE. Thank you very much.

Not really. The XPath Data Model doesnbt preserve entity information or
notations (notations are kind of weird in XML anyway). As Wendell
pointed out, you can get some of the information back, if you know where
to look. But you arenbt going to be able to persuade the serializer to
reproduce the internal subset for you.

If you can move everything into the external subset, all you have to
reproduce is the doctype declaration which you can do with xsl:output.

If youbre determined, and not too worried about a slightly brittle
solution, you can try something like this:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                xmlns:xs="http://www.w3.org/2001/XMLSchema";
                exclude-result-prefixes="xs" expand-text="yes"
                version="3.0">

<xsl:character-map name="angle-brackets">
  <xsl:output-character character="B+" string="&lt;"/>
  <xsl:output-character character="B;" string="&gt;"/>
</xsl:character-map>

<xsl:output method="xml" encoding="utf-8" indent="yes"
use-character-maps="angle-brackets"/>

<xsl:strip-space elements="Document"/>

<xsl:mode on-no-match="shallow-copy"/>

<xsl:template match="/">
  <xsl:text>&#10;B+!DOCTYPE Document SYSTEM "graphics.dtd" [&#10;</xsl:text>
  <xsl:text>B+!NOTATION jpeg PUBLIC ""B;&#10;</xsl:text>
  <xsl:for-each select="//Graphic">
    <xsl:text>B+!ENTITY {@boardno} SYSTEM "{unparsed-entity-uri(@boardno)}"
NDATA jpegB;&#10;</xsl:text>
  </xsl:for-each>
  <xsl:text>]B;&#10;</xsl:text>
  <xsl:apply-templates/>
</xsl:template>

</xsl:stylesheet>

But thatbs not very robust.

                                        Be seeing you,
                                          norm

--
Norman Tovey-Walsh <ndw@xxxxxxxxxx>
https://nwalsh.com/

> An ill-humoured man is a prisoner at the mercy of an enemy from whom he
> can never escape.--Sa'di

[demime 1.01d removed an attachment of type application/pgp-signature which had a name of signature.asc]

Current Thread