Re: declare entity in including document, use it in stylesheet

"Anthony Jones" <[email protected]> Mon, 31 Dec 2007 13:56:52 -0000
Newsgroups gmane.comp.mozilla.devel.layout.xslt
Message-ID <[email protected]>
"Travis Staloch" <[email protected]> wrote in message
news:[email protected]...
> I have an xml document with a xml-stylesheet processing instruction.  I'm
trying to declare an entity in the xml document and have the xsl recognize
that entity.  Can anyone comment on whether this is possible in this
situation?  I could accomplish the same by putting this info (a file name)
in an xml field.  But for some reason, it seemed natural to do it this way.
>
> TIA,
>
>
>
> Travis
>
>
> my xml document:
> -----------
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE config [
>   <!ENTITY % fileName SYSTEM "Config.xml">
>   %fileName;
> ]>
>
> <?xml-stylesheet type="text/xsl" href="editor.xsl"?>
> <config>
>  ...
> </config>
>
> and in the editor.xsl, I'm attempting to use the entity &fileName; with no
luck.  Firefox gives the error:
> XML Parsing Error: undefined entity
>


That's because fileName is a parameter entity designed to insert external
DTD into the current DTD.  IOW the parser is expecting Config.xml to contain
DTD which is inserted at %fileName;.  No &fileName entity created.

If Config.xml contains XML then drop % in the entity definition and drop the
%fileName; from the doc type.

Add &fileName; in the XML where you wish it to be inserted.

-- 
Anthony Jones - MVP ASP/ASP.NET