Hi Ken,
"Rodent of Unusual Size" <[EMAIL PROTECTED]> writes:
> Okey, I tried that, and I ran into an entirely new set of problems:
>
> use XML::Xerces;
> use XML::Xerces::DOMParse;
>
> $DOMimpl = XML::Xerces::DOM_DOMImplementation::getImplementation();
> $doctype = $DOMimpl->createDocumentType('lexicon', '', 'ap-dict.dtd');
> $doc = $DOMimpl->createDocument('lexicon', 'lexicon', $doctype);
> $XMLdecl = $doc->createXMLDecl("1.0", "utf-8", 'yes');
> $doc->appendChild($XMLdecl);
> $XML::Xerces::DOMParse::INDENT = " ";
> XML::Xerces::DOMParse::format($doc);
> XML::Xerces::DOMParse::print(\*STDOUT, $doc);
The problem is after you run createDocument() your document already
has two child nodes, the doctype node, and an element node
<lexicon/>. When you use appendChild() it puts the XMLDecl node in the
wrong place, it wants to be first in the list, so use insertBefore():
DB<19> $doc->insertBefore($XMLdecl,$doctype)
DB<20> x $doc->getChildNodes
0 XML::Xerces::DOM_XMLDecl=HASH(0x1066baa8)
empty hash
1 XML::Xerces::DOM_DocumentType=HASH(0x1066cb08)
empty hash
2 XML::Xerces::DOM_Element=HASH(0x1066ca60)
empty hash
DB<21> XML::Xerces::DOMParse::print(\*STDOUT,$doc)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE lexicon SYSTEM 'ap-dict.dtd' >
<lexicon/>
> > > I am finding the Xerces-P and Xerces-C documentation pretty
> > > bloody opaque. For instance, one major facet it seems to be
> > > missing is *examples*..
> >
> > Yes, that seems to be everyones comment. So far, I have no
> > takers for helping me improve the docs (nor, in fact, have I
> > had any volunteers to help me improve the code, which would
> > also be welcome ;-)
>
> I would be glad to help out if and how. I do a lot of writing,
> and my incredibly neophyte perspective on this stuff might be
> useful.
Ok, I'll start a discussion on the list of what needs to be done and
different ways that we can do it.
> > > 2. How can I persuade the printing method to *not* turn "
> > > into " in my processing instructions??? 'type="text/css"'
> > > gets turned into 'type="text/css"' which is really
> > > annoying..
> >
> > Hmmm... I would fiddle with
> > $parser->setCreateEntityReferenceNodes(). If you set this to '1' it
> > should leave your entities alone. Let us know if this succeeds.
>
> Well, I *want* entities encoded everywhere except in the
> processing directives.
Sorry, I'm not sure. I've found some other issues with how Xerces
handles entities, so I haven't dug into it much further...
jas.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]