Re: [xsl] Resolving character entities

Subject: Re: [xsl] Resolving character entities
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 15 Feb 2024 16:00:47 -0000
On 15/02/2024 16:52, rick@xxxxxxxxxxxxxx wrote:
>
> Hi All,
>
> I have this as the input:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!DOCTYPE subtask [
>
> <!ENTITY lt "&#38;">
>
> <!ENTITY gt "&#62;">
>
> <!ENTITY amp "&#38;">
>
> ]>
>
> <subtask>
>
> B B B  <title>General Information</title>
>
> B B B  <prcitem1>
>
> B B B B B B B  <prcitem>
>
> B B B B B B B B B B B  <para>This document provides &lt; repair
instructions
> &amp; for the Fire Extinguisher components.</para>
>
> B B B B B B B  </prcitem>
>
> B B B  </prcitem1>
>
> </subtask>
>
> I want all of the entities to be resolved when I transform the file.
> This is my stylesheet:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>
> xmlns:xs="http://www.w3.org/2001/XMLSchema";
>
> xmlns:math="http://www.w3.org/2005/xpath-functions/math";
>
> B B B  exclude-result-prefixes="xs math"
>
> B B B  version="3.0" expand-text="yes">
>
> B B B B <xsl:output indent="yes"/>
>
> B B B B <xsl:template match="/">
>
> B B B B B B B  <xsl:apply-templates/>
>
> B B B  </xsl:template>
>
> B B B B <xsl:mode on-no-match="shallow-copy"/>
>
> </xsl:stylesheet>
>
> This is my output:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <subtask>
>
> B B  <title>General Information</title>
>
> B B  <prcitem1>
>
> B B B B B  <prcitem>
>
> B B B B B B B B  <para>This document provides &lt; repair instructions
&amp;
> for the Fire Extinguisher components.</para>
>
> B B B B B  </prcitem>
>
> B B  </prcitem1>
>
> </subtask>
>
> I was thinking that my $lt; should have been substituted with &#38;,
> etc. Does it not matter because these are bvalidb XML entities? Thank
you.
>

The result tree is serialized by the XSLT processor or its serializer,
it doesn't really matter whether there was a certain character,
character refererence or entity reference in the input.

If you want to control the output serialization, consider to use
character map.

Current Thread