<!{CDATA[]]> and <ELEMENT> in a xml element

Antt

I'm currently trying to write a DTD for an XML file.

In the xml I came across this type of things :

<CHAMP NAME="JBRTHDTC" DOMAIN="DM" DB="YES:CRF" TYPE="JOUR" FORCED="YES" AFFICHE="YES">
    <![CDATA[ Date de naissance: ]]>
    <MESSAGE><![CDATA[Date de naissance (Jour)]]></MESSAGE>
</CHAMP>    

Is it ok to have CDATA and a xml element inside another?

If so, how can I manage to write it in DTD? Like

ELEMENT CHAMP (MESSAGE?|CDATA??)>
Daniel Haley

You have to declare CHAMP as a mixed content model.

This means that CHAMP can contain either #PCDATA (parsed character data) or MESSAGE. (You can still have CDATA sections in the mixed content model.)

This has to be declared a certain way, so you won't be able to limit the number of occurrences of MESSAGE. It's zero or more #PCDATA or MESSAGE in any order.

Example:

<!DOCTYPE CHAMP [
<!ELEMENT CHAMP (#PCDATA|MESSAGE)*>
<!ATTLIST CHAMP
        NAME    CDATA #IMPLIED
        DOMAIN  CDATA #IMPLIED
        DB      CDATA #IMPLIED
        TYPE    CDATA #IMPLIED
        FORCED  CDATA #IMPLIED
        AFFICHE CDATA #IMPLIED>
<!ELEMENT MESSAGE (#PCDATA)>
]>
<CHAMP NAME="JBRTHDTC" DOMAIN="DM" DB="YES:CRF" TYPE="JOUR" FORCED="YES" AFFICHE="YES">
    <![CDATA[ Date de naissance: ]]>
    <MESSAGE><![CDATA[Date de naissance (Jour)]]></MESSAGE>
</CHAMP>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related