You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Kapa, Madhavi" <ma...@marconimed.com> on 2000/08/29 15:38:35 UTC

Order of elements in an XML file?

Hi,

  I have an XML file with a DTD as 

<?xml version="1.0"?>
<!DOCTYPE coreconfig [
  <!ELEMENT name       (#PCDATA)>
  <!ELEMENT actionname (#PCDATA)>
  <!ELEMENT styleset   (#PCDATA)>
	    
  <!ELEMENT delegate   (#PCDATA)>
  <!ELEMENT type       (#PCDATA)>
  <!ELEMENT id         (#PCDATA)>
  <!ELEMENT checksum   (#PCDATA)>
  <!ELEMENT coreconfig (action)+>
  <!ELEMENT action     (name,actionname*,stylesheet+,delegate,license?)>
  <!ELEMENT stylesheet (name,styleset?)>
  <!ELEMENT license    (type,id,checksum)>
]>
<coreconfig>
    <action>
        <name>login</name>
        <actionname>logon</actionname>
        <stylesheet>
            <name>login.xsl</name>
            <styleset>marconi</styleset>
        </stylesheet>
        <delegate>class1</delegate>
        <license>
            <type>e</type>
            <id>10</id>
            <checksum>c1</checksum>
         </license>
    </action>
 </coreconfig>


The order of elements in
action(name,actionname*,stylesheet+,delegate,license?) or
stylesheet(name,styleset?) or
license(type,id,checksum) is now fixed. I have to specify these elements
under action, stylesheet and license in this order in the XML file.

My question is how do I specify the DTD such that the sequence in which the
elements of action, stylesheet and license occur in the XML file
does not matter.

Thanks, 
Madhavi


Re: Order of elements in an XML file?

Posted by Andy Clark <an...@apache.org>.
Please remember that using the Schema "all" group or expanding
a content model in a DTD is a factorial problem. It can get
out of hand very quickly as the number of elements increases.

I much prefer to put a restriction on the order of elements --
this simplifies the model and improves validation performance
as well.

-- 
Andy Clark * IBM, JTC - Silicon Valley * andyc@apache.org