[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Using grammars to generate XML data

  • From: "Amit Rekhi" <amitr@a...>
  • To: "xml list" <xml-dev@i...>
  • Date: Wed, 30 Jun 1999 16:54:15 +0530

generate xml data
Hello,

PROBLEM STATEMENT
Traditionally, an XML grammar (something like what's defined in the spec)
is used by parsers to check the syntax of input XML files
for conformance to XML.
My problem:
- Is it proper usage of an XML grammar to be used by
XML data generators to generate XMLised data?i.e
I am wanting to use an XML grammar not to validate XML data
but to generate XMLised data conforming to that grammar.
 Is it logical, proper to be using an
XML grammar for driving a XMLised data generator application?
- If yes, how would such a XML data generator
implement the production rules and use them to generate XMLised data?

Let me explain my point with an example.
Let's say I have the following XML grammar:

[1] Document  := '<Document>' (Element)+ '</Document>'
[2] Element     := '<Element>' CharData '</Element>'
[3] CharData  := [^<&]* - ([^<&]* ']]>' [^<&]*)

Let's say I wish to build an XMLised data generator which
would take the following input  stream:
'abc'
and produce the following output stream:
<Document>
  <Element>a</Element>
  <Element>b</Element>
  <Element>c</Element>
</Document>
This is an XMLised version of the input stream conforming to rules 1-3
above.
In order to produce the above XMLised output thru the XMLised generator
I am planning
- To let the data generator use rules 1-3 i.e.
For an input 'abc' the data generator would
- start building a syntax tree with non terminal 'Document' as the root,
looking at rule [1],
- On each character of the input stream encountered, the 'Element' non
terminal
(rule [2]) present in rule [1] would be expanded and the current input
character
would replace the 'CharData' non terminal in rule [2]
This way I can get the the entire XMLised output as a parse tree using the
XML grammar. This XML parse tree can then be outputted to a file.

- Would it be proper grammar usage to be writing a 'XML data generator'
application which would use rules 1-3 to generate XML data
conforming to rules 1-3?
- Are there any such data generators available?If so I'd be
grateful if someone could pass me relevant pointers on the web.
- How would such a data generator application implement
the grammar rules?
Thanks in advance for any replies,


Amit Rekhi,
Software Engineer,
A.B. Infosys Private Limited,
B-102, Gulmohar Park,
New Delhi - 110049,
INDIA.
Tel: +91-11-6512816,6512822,6968976
Fax: +91-11-6518873
Website: http://www.abinfosys.com
EMail: amit@a...



xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo@i... the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.