Re: [xsl] Why aren't ENTITY declarations in a main stylesheet visible in the included stylesheets?

Subject: Re: [xsl] Why aren't ENTITY declarations in a main stylesheet visible in the included stylesheets?
From: "Norm Tovey-Walsh ndw@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 2 Jun 2022 11:19:59 -0000
> I thought that an xs:include is essentially a "macro substitution", in
> which case the entity declaration should be visible, yes?

Nope. The XPath data model doesnbt have entities in it, so the parser
expands them away. (In principle, the parser doesnbt have to, but the
result wonbt work in XSLT if it doesnbt.)

> I don't want to have ENTITY declarations scattered around multiple
> files. What's the best way to deal with ENTITIES?

If all your tooling will read the external subset, you can do something
like this:

<!DOCTYPE whatever SYSTEM "whatever.dtd" [
<!ENTITY % myDecls SYSTEM "decl.ent">
%myDecls;
]>
<whatever>
&spoon;
</whatever>

where decl.ent contains the entities, for example:

<!ENTITY spoon "Spoon!">

You can get them into your XSLT that way too:

<!DOCTYPE xsl:stylesheet [
<!ENTITY % myDecls SYSTEM "decl.ent">
%myDecls;
]>
<xsl:stylesheet>b&

But you have to do that in every file (including the ones you include or
import).

See also this note from ~20 years ago:

  https://norman.walsh.name/2003/09/27/dtds

:-)

                                        Be seeing you,
                                          norm

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

> Why do politicians lie? Because it works.

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

Current Thread