RE: [xsl] DTD question

Subject: RE: [xsl] DTD question
From: "Brinkman, Theodore" <Theodore.Brinkman@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 24 Jan 2003 16:48:54 -0500
If I'm reading it right, the original element line says that adresse
contains one of vorname, nachname, or othername, and zero or one of telefon,
fax, strasse, plz, or stadt.

Your suggestion (again, if I'm reading it right), would say adresse contains
one of vorname, nachname, or othername, zero or one of telefon, zero or one
of fax, zero or one of strasse, zero or one of plz, and zero or one of
stadt.

The only way I can think of to get what he's wanting is to do a very complex
list of child elements  Two short examples follow:


<!ELEMENT parent1 (((child1?,child2?)|(child2?,child1?)))>

<!ELEMENT parent2
(((child1?,child2?,child3?)|(child1?,child3?,child2?)|(child2?,child1?,child
3?)|(child2?|child3?,child1?)|(child3?,child1?,
child2?)|(child3?,child2?,child1?)))>


The parent1 definition would allow any combination of zero, one, or two
child elements consisting of no more than one of each child1, and child2.

The parent2 definition would allow any combination of zero, one, two, or
three child elements consisting of no more than one of each child1, child2,
and child3.

You can see that this gets quite a bit more complicated as the number of
child elements increases.  Easier (but less effective) would be this.
<!ELEMENT parent3 ((child1|child2|child3)*)>

The parent3 definition allows any number of child1, child2, and/or child3
elements in any order.

If you really want order independant information, and you can control the
XML you recieve, just stick those bits of data in attributes instead of
child elements (assuming none of these bits have children of their own).

If you can't control the XML you recieve, and the people giving it to you
can't guarantee the order of the elements, ask *THEM* for a valid DTD.  :)

	- Theo

-----Original Message-----
From: Lopez, William [mailto:william.lopez@xxxxxxx]
Sent: Friday, January 24, 2003 4:04 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] DTD question


Hubert:
I'm no XML expert but I believe the following statement goes against what a
DTD is supposed to do:

>but the order is not important...

A DTD's function is to make sure the XML conforms to the specified
structure.
I'm not certain if your use of the optional '?' operator is correct...

><!ELEMENT adresse ((vorname|nachname|othername),(telefon|fax|strasse|plz
			|stadt)?)>

...try this
<!ELEMENT adresse
((vorname|nachname|othername),telefon?,fax?,strasse?,plz?,stadt?)>

...there are tons of sites out there...here is a searchable list archive...
http://lists.xml.org/archives/xml-dev/

HTH,
-Will
-----Original Message-----
From: Hubert Holtz [mailto:Turnhose_alt@xxxxxxx]
Sent: Friday, January 24, 2003 1:47 PM
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] DTD question


Hy,

I know that this is not a real XSL question, but it's connected with this
topic :-)

I have an element adress with several elements in it(prename, name, fax,
phone,street...)
and I want that these elements only may appear once, but the order is not
important, and that prename and name have to appear, the rest
don't have to but if they appear then just once of course.

How do I tell the dtd to do this?


I thought of something like this:

<!ELEMENT adresse ((vorname|nachname|othername),(telefon|fax|strasse|plz
			|stadt)?)>
	<!ELEMENT vorname (#PCDATA)>
	<!ELEMENT nachname (#PCDATA)>
	<!ELEMENT othername (#PCDATA)>
	<!ELEMENT telefon (#PCDATA)>
	<!ELEMENT fax (#PCDATA)>
	<!ELEMENT strasse (#PCDATA)>
	<!ELEMENT plz (#PCDATA)>
	<!ELEMENT stadt (#PCDATA)>


But this doesn't do what it is supposed to do and I know that this is not
working correctly because it's false for my needs, but i don't know how to
code it right.
Any suggestions or tutorial sites which are going a little bit deeper into
this topic than the zvon or equal stuff are welcome.

Thanks.
Homer30


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread