ewitness - Ben Fowler wrote:
> At 4:10 pm +0100 9/2/02, Joerg Pietschmann wrote:
> >[EMAIL PROTECTED] (ewitness - Ben Fowler) wrote:
> >>  Yes, you can use &#number;, and this sometimes proves easier.
> >
> >I'm not sure want you are trying to say... Do you still edit
> >your XML files with a plain text editor?
> >
> >[ snip ]
> >
> >  > I don't suppose that SKS could post a short complete file which
> >  > would have this as its meat.
> >  >       <para>&ldquo;Hello World!&rdquo;</para>
> OK I was in error in expecting you to do my work for me.
> I am trying to write something like:
>         <?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
>         <!DOCTYPE example [
>                 <!ENTITY ldquo  "&#x201C;"> <!--  -->
>                 <!ENTITY rdquo  "&#x201D;"> <!-- RIGHT DOUBLE
>         ]>
>         <example>
>            <title>A Canonical Greeting</title>
>            <para>&ldquo;Hello World!&rdquo;</para>
>         </example>
> Which is an XML document having a root element (as it must), and
> some very simple content.
> Less usually, I want to declare some ENTITYs in the internal subset
> so I that I can use them without specifying an external subset.
> When I try to parse it with ElfData XML Editor
> <URL: http://www.elfdata.com/xmleditor/ >, I get this error
>         XML-Validity: Your XML is a well-formed document, but it
>         conflicts with the DTD:
>         Invalid DOCTYPE tag. The root 'example' specified in the
>         DOCTYPE, was not defined in the DTD.
> (I get the same error if I have no structure to the root
> element, as:
> <?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
> <!DOCTYPE para  [
>         <!ENTITY ldquo  "&#x201C;"> <!--  -->
>         <!ENTITY rdquo  "&#x201D;"> <!-- RIGHT DOUBLE QUOTATION MARK -->
> ]>
> <para>&ldquo;Hello World!&rdquo;</para>
> ).
> My problem being "What DTD?". Sure, I declare that my document
> is of type example, and use that as the root element, but I never
> specify what a document's being an 'example' means beyond how
> I have uses tags and other content within it. Personally, I wouldn't
> recognise the DOCTYPE tag as invalid, see
> <URL: http://www.xml.com/pub/a/98/08/xmlqna2.html >, and perhaps
> more useful <URL: http://www.oreillynet.com/pub/faqs/xml_faq_validwf >,
> but I may be wrong.

You are stating that the document contains an 'example' tag
as the root element, but not stating what the root element
contains is an error.
The following XML is valid:

<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<!DOCTYPE example [
<!ELEMENT example (title,para)>
<!ELEMENT title (#PCDATA)>
<!ENTITY ldquo  "&#x201C;"> <!--  -->
 <title>A Canonical Greeting</title>
 <para>&ldquo;Hello World!&rdquo;</para>

This, coupled with a simple xml-to-fo xslfile renders a
proper PDF using fop.

If you want to declare an external DTD and declare entities
in the internal subset it would look like this:

<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
<!DOCTYPE example SYSTEM "special.dtd" [
<!ELEMENT example (title,para,special?)>
<!ELEMENT title (#PCDATA)>
<!ENTITY ldquo  "&#x201C;"> <!--  -->
 <title>A Canonical Greeting</title>
 <para>&ldquo;Hello World!&rdquo;</para>
 <special>This tag defined in external subset</special>

Here the 'special' tag is defined in the external subset,
defined in the file special.dtd

Also note the standalone attribute set to "no" to reflect
the usage of an external dtd.
A validating parser should read the external DTD, whereas a
non-validating may, but is not required to, even if
standalone is set to "no".
Basically this means that if the external subset contains
declarations with consequences for a document's content, the
document's content depends on the parser in use and how it
is configured.

XML in a nutshell is a good book on the subject, btw.

Hope this helps!

///Magnus Sj÷berg

> When I try to parse this document with SAX, I get this
> error,
>         SystemId Unknown; Line 0; Column 0; SystemId Unknown; Line 0;
> Column 0; SAX Exception
> which again again I thought was odd, because I specifically didn't have
> SystemId (but that is consistent in a blunt sort of way with the SystemId's
> being unknown). I could easily have written the DOCTYPE as
>         <!DOCTYPE example SYSTEM "./docbookx.dtd">
> which is most precisely which I did not want to do. (SAX does
> parse (correctly) the elided version).
> In short, how do I best declare ENTITYs in a standalone XML
> document?
> If you wish, you could point me to a page reference in either the
> Chick book, or the Duck book as I have both beside me.
> Ben

Reply via email to