Search code examples
xmldtdpcdata

DTD syntax - allow sub element OR pcdata


My .xml structure may have the following data:

<entry id="one-string">
            <class>nmWinMultiReports_main</class>
            <classParams>string</classParams>
         </entry>
<entry id="multiple-elements">
            <class>nmJavaScript_main</class>
            <classParams>
               <pluginid>monitorPlugin</pluginid>
               <bla>string</bla>
               <tag>abc</tag>
            </classParams>
         </entry>

How do I define the .dtd file to allow classParams to either 1. be a string or 2. multiple sub elements (each once)?

I tried:

<!ELEMENT class ( #PCDATA ) >
<!ELEMENT classParams ( #PCDATA | pluginid | bla | tag ) >
         <!ELEMENT pluginid ( #PCDATA ) >
         <!ELEMENT bla ( #PCDATA ) >
         <!ELEMENT tag ( #PCDATA ) >

Solution

  • I made it:

    <!ELEMENT classParams ( #PCDATA | pluginid | bla | tag )* >