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

Re: Create XML


c create xml
From: "Simon St.Laurent" <simonstl@s...>
> ><!ELEMENT A
> >((B)|(C)|(D)|(B,C)|(B,D)|(C,D)|(C,B)|(D,B)|(D,C)|(B,C,D)|(B,D,C)|(C,B,
> >D)|(C,D,B)|(D,B,C)|(D,C,B)) >
> >
> >That said, this is enough to make order constraints required rather
> >than useful, with 20 children this becomes so tedious the errors are
> >almost guaranteed.
>
> Doesn't that trip over the requirement at:
> http://www.w3.org/TR/REC-xml#sec-element-content
>
> "The content of an element matches a content model if and only if it is
> possible to trace out a path through the content model, obeying the
> sequence, choice, and repetition operators and matching each element in
> the content against an element type in the content model. For
> compatibility, it is an error if an element in the document can match
> more than one occurrence of an element type in the content model."

(I like little puzzles like this, so please excuse.)

Yes, it does. The expression seems to be trying to solve the problem: at
most one of each term in any order but at least one of some term. You need
to factor this answer to make it unambiguous, e.g.,

(D,((B,C?)|(C,B?))?) | (B,((D,C?)|(C,D?))?) | (C,((D,B?)|(B,D?))?)

Tedium is in the eye of the beholder. One could write a program to generate
this stuff, along the lines of:

e([A]) = A
e(cons(x,y)) = (x,e(y)?)|(e(cons(head(y),cons(x,tail(y))))

But it will still be exponential in the number of elements, so you will not
like the result for 32 elements. ;-}

People often respond that this question is a FAQ, but actually it seems to
be a FWAQ (Frequently Wrongly Answered Question).

> RELAX NG seems to have these kinds of problems under control, at least
> for my purposes.

In RELAX NG, the answer is:

A|B|C|(A?&B?&C?)

RELAX NG validators avoid the exponential expansion vs. backtracking issues
by evaluating only the branch of the tree that matches the input. Superior
technology trumps implementation-motivated restrictions! (Which is what the
next generation will say about RELAX NG. ;-)

Bob Foster


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.