You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Jason E. Stewart" <ja...@openinformatics.com> on 2001/07/09 17:03:54 UTC
XML Character entities
Norm Walsh has made XML versions of the ISO character entities. Check
out:
http://docbook.sourceforge.net/projects/xmlcharent/index.html
We could distribute these with Xerces, could we not? Or at least
include the URL in the documentation as a useful reference.
jas.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: Force use of a known DTD
Posted by Alberto Massari <al...@exceloncorp.com>.
At 12.45 12/07/01 +0200, you wrote:
>Hi all,
>
>I've got an application where I use XML documents that _must_ adhere to a
>certain, known, DTD.
>What I'd like to be able to do is force my DOMParser (or its Validator, or
>whatever) to always use a DTDValidator with that DTD to validate documents,
>even if their DOCTYPE is missing or says they're of a different type (if the
>document is of a different type, I can't successfully use it)
>I've looked closely at DTDValidator, but even creating my own validator
>won't help, because its scanDocTypeDecl() method will only be called if a
><DOCTYPE entry is found.
>Is there any way of achieving this?
The code I use for this task is this (but I use it to validate XML files
that don't have a DOCTYPE entry, so I am not sure it works if there is one):
XMLByte* dummyXML="<?xml version=\"1.0\"?><!DOCTYPE myDtdRoot SYSTEM
\"MyFixedDTD.dtd\"><myDtdRoot/>";
MemBufInputSource inputSource(dummyXML,strlen(dummyXML),"dummy",false);
SAXParser sp;
sp.setDoValidation(true);
sp.parse(inputSource);
// now, reuse the validator and parse the new doc
FileInputSource inputSource2("somefile.xml");
sp.parse(inputSource2, true);
Hope this code is really working (as I removed a lot of extra stuff to get
the core of the routine) and it helps you,
Alberto
-------------------------------
Alberto Massari
eXcelon Corp.
http://www.StylusStudio.com
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: Force use of a known DTD
Posted by Andrew Snare <AS...@allshare.nl>.
At 12:45 PM 12/07/2001 +0200, Evert Haasdijk wrote:
>I've got an application where I use XML documents that _must_ adhere to a
>certain, known, DTD.
>What I'd like to be able to do is force my DOMParser (or its Validator, or
>whatever) to always use a DTDValidator with that DTD to validate documents,
>even if their DOCTYPE is missing or says they're of a different type (if the
>document is of a different type, I can't successfully use it)
>I've looked closely at DTDValidator, but even creating my own validator
>won't help, because its scanDocTypeDecl() method will only be called if a
><DOCTYPE entry is found.
>Is there any way of achieving this?
I'm not sure there's a way to do what you say. However, the approach we use
where we need to force 1) a specific DTD and 2) validation is:
1) Use a DOCTYPE PUBLIC definition which uses a "public" identifier for the DTD
you wish to use.
2) Check the doctype recorded in the DOM tree after the parse. If it's not
correct, we turf it.
3) We attach an entity resolver to the parser that ignores all requests except
for our public identifier from step 1). We then return our 'known' DTD.
This approach may be sufficient for your needs.
- Andrew
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Force use of a known DTD
Posted by Evert Haasdijk <ev...@zukkespijkers.nl>.
Hi all,
I've got an application where I use XML documents that _must_ adhere to a
certain, known, DTD.
What I'd like to be able to do is force my DOMParser (or its Validator, or
whatever) to always use a DTDValidator with that DTD to validate documents,
even if their DOCTYPE is missing or says they're of a different type (if the
document is of a different type, I can't successfully use it)
I've looked closely at DTDValidator, but even creating my own validator
won't help, because its scanDocTypeDecl() method will only be called if a
<DOCTYPE entry is found.
Is there any way of achieving this?
TIA, Evert
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: inlining a DTD
Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Evert Haasdijk" <ev...@zukkespijkers.nl> writes:
> Thanks for your suggestion, although I'm not sure how to 'build the
> <!DOCTYPE ...> myself' Could you illustrate with some (pseudo)code ?
You just want to build a string piece by piece, then read in the dtd,
then close the doctype;
I'm Sorry Evert, but I'm really the Xerces-Perl maintainer, so I do
all my string manipulations using Perl strings, which are a lot easier
to deal with than DOMString's or XMLCh*'s. So I'll just give you the
basic idea.
DOMString doctype_open("<!DOCTYPE ");
doctype_open += DOMString("your_doc_name_here");
doctype_open += DOMString(" SYSTEM");
doctype_open += DOMString("your_doc_path_here");
doctype_open += DOMString("[");
DOMString doctype_close("]]>");
Then read your DTD into another string:
DOMString my_dtd;
And then piece them all together with my_dtd between doctype_open and
doctype_close:
doctype_open += my_dtd;
doctype_open += doctype_close;
I'm sure I've screwed up the syntax.
jas.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
RE: inlining a DTD
Posted by Evert Haasdijk <ev...@zukkespijkers.nl>.
Jason,
Thanks for your suggestion, although I'm not sure how to 'build the
<!DOCTYPE ...> myself' Could you illustrate with some (pseudo)code ?
TIA, Evert
> -----Original Message-----
> From: Jason E. Stewart [mailto:jason@openinformatics.com]
> Sent: Tuesday, July 10, 2001 17:43 PM
> To: xerces-c-dev@xml.apache.org
> Subject: Re: inlining a DTD
>
>
> "Evert Haasdijk" <ev...@zukkespijkers.nl> writes:
>
> > Is there any way to inline the DTD for a DOM document so that, after
> > writing the document, it has an inline DTD?
>
> My solution is to start my parse with a bare bones document
> constructed in a memory buffer. Then I read my DTD in from a disk
> file, and build the <!DOCTYPE ...> my self and append it the document
> I started, and then start the parser on the inputsource from the
> membuf.
>
> jas.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: inlining a DTD
Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Evert Haasdijk" <ev...@zukkespijkers.nl> writes:
> Is there any way to inline the DTD for a DOM document so that, after
> writing the document, it has an inline DTD?
My solution is to start my parse with a bare bones document
constructed in a memory buffer. Then I read my DTD in from a disk
file, and build the <!DOCTYPE ...> my self and append it the document
I started, and then start the parser on the inputsource from the
membuf.
jas.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
inlining a DTD
Posted by Evert Haasdijk <ev...@zukkespijkers.nl>.
Hi all,
Is there any way to inline the DTD for a DOM document so that, after writing
the document, it has an inline DTD?
TIA, Evert
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org