xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas B. Passin" <tpas...@mitretek.org>
Subject Re: getting a list of valid elements
Date Fri, 26 Jan 2001 22:21:56 GMT
xmlproc, a python parser, lets you get at the dtd information.  It's at


Being python, I'm pretty sure it would work using JPython with java. You
can use it to parse just the dtd, then you could use Xerces or whatever
to parse the bulk of the document.  Or, use only the dtd info while
authoring.  The dtd interface can give you content model and a list of
the elements for any element, which is probably what you want.

<mandy.shaw@uk.catalyst-solutions.com> wrote -

> I have been down this route too, with zero success (in fact I posted a
> question on this list & got no responses at all). It seems quite
> extraordinary, and very irritating, that you cannot obtain this
> through DOM when it's all there in the DTD. Of course you can read the
> line by line & parse it yourself, but I worked around it another way
in my
> application.
> If you get any joy, please keep me posted - would appreciate it a lot.
> Mandy
> Patrick Lightbody <plightbo@cisco.com> on 26/01/2001 01:25:25
> Please respond to general@xml.apache.org
> To:   general@xml.apache.org
> cc:    (bcc: Mandy Shaw/Pacific/UK)
> Subject:  getting a list of valid elements
> I have explored using Xerces and Oracle's XML parsers to be able to
> a simple web-based XML editor. Consider this sample use-case:
> I have a DTD or XML Schema that defines the grammar as:
> <foo>
> <bar item="1">#PCDATA</bar>
> <bar item="2">#PCDATA</bar>
> <bar item="3">#PCDATA</bar>
> ...
> <bar item="n">#PCDATA</bar>
> </foo>
> I need to present a web-based form for one textfield with input for
> PCDATA for "bar #1". Since the grammar defines that <foo> must have 1
> more <bar> elements. So somehow I need to get my class to "know" that
> can have one or more "bar" elements. It must also know that "bar" can
> no child elements, but can have many "bar" siblings. Is this possible?
> Spy has helpers in the application that present the "expected
> defined by the XML grammar, yet I can't find any parser that allows
> this.
> Obviously if a validating parser can throw an Exception if I add an
> *unexpected* element to the tree, it must somehow know which elements
> *expected*. Is it possible to get that list of expected elements? With
> "list" of expected child and sibling elements, I could be able to
build a
> simple web-bases XML editor that would prompt for data inputs,
> independent of the XML schema/DTD.
> -Pat

View raw message