Topic
  • 5 replies
  • Latest Post - ‏2011-02-27T16:17:24Z by SystemAdmin
kein-stress
kein-stress
1 Post

Pinned topic DTD validation

‏2011-01-15T13:16:20Z |
Hey guys,

I would kindly ask you to do me a favor by answering and explaining
these terms regarding validation of DTD.

the code of dtd looks like that:

<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT A (B*,C*)>
<!ELEMENT B (C+,B?)>
<!ATTLIST B K ID #REQUIRED>
<!ELEMENT C (#PCDATA|D|E)*>
<!ELEMENT D (#PCDATA)>
<!ELEMENT E EMPTY>
<!ATTLIST C L IDREF #IMPLIED>

are the below terms valid or not:

1. abc<C>cde<D>fgh</D></C> 2. <C>abc</C><C>fgh</C> 3. <C>abc</C><C L="A2">def</C> 4. <C><E/><E></E></C> 5. <C><E><E/></E></C> 6. <C><D>abc</D></C><C>def</C> 7. <C><D>abc</D></C><C>def</C> 8. <C></C>
I have read few times docs about DTD, but some stuff is still not
understandlable for me.
Any answer and explanation would be really appreciated.

Best regards,
Kamilov
Updated on 2011-02-27T16:17:24Z at 2011-02-27T16:17:24Z by SystemAdmin
  • nguyendackhoa
    nguyendackhoa
    1 Post

    Re: DTD validation

    ‏2011-01-16T15:13:59Z  
    sorry, my English is not good.But i will try. I also study XML _DTD _ SCHEMAS
    We see ELEMENT C :
    *<!ELEMENT C (#PCDATA|D|E)*>*
    this means :
    • between <C> and </C> can have a text or Element D or Element E.only one not all.So abc<C>cde<D>fgh</D></C> is wrong.
    • *(*#PCDATA|D|E*)** can have much more than a text or a Element D or a Element E. So <C>abc</C><C>fgh</C> is correct.

    <!ATTLIST C L IDREF #IMPLIED>
    this means :
    • <C L=""> </C> IDREF :The value is the id of another element(EX: ""> before ---> <C L=*"A2"*></C>).#IMPLIED :The attribute is not required (L="" can have or not). So <C>abc</C><C L="A2">def</C> is not sure if A2 existed.
    *<!ELEMENT C (#PCDATA|D|E)*>*
    <!ELEMENT D (#PCDATA)>
    <!ELEMENT E EMPTY>
    this means :
    • between <C> </C> can have many ELEMENT E and E can be empty ( <E/> or <E> </E> ). So <C> <E/> <E> </E> </C> is correct.
    • <C><E><E/></E></C> is wrong beacause E is empty <E> </E> don't has anything.
    • between <C> </C> can have one or many ELEMENT D and D can be a text.beside ELEMENT C also have one or many beacause * . <C><D>abc</D></C><C>def</C is correct.
    • between <C> </C> can have Zero or More cause *
    http://www.w3schools.com/DTD/dtd_elements.asp
  • SystemAdmin
    SystemAdmin
    1138 Posts

    Re: DTD validation

    ‏2011-02-26T22:16:52Z  
    sorry, my English is not good.But i will try. I also study XML _DTD _ SCHEMAS
    We see ELEMENT C :
    *<!ELEMENT C (#PCDATA|D|E)*>*
    this means :
    • between <C> and </C> can have a text or Element D or Element E.only one not all.So abc<C>cde<D>fgh</D></C> is wrong.
    • *(*#PCDATA|D|E*)** can have much more than a text or a Element D or a Element E. So <C>abc</C><C>fgh</C> is correct.

    <!ATTLIST C L IDREF #IMPLIED>
    this means :
    • <C L=""> </C> IDREF :The value is the id of another element(EX: ""> before ---> <C L=*"A2"*></C>).#IMPLIED :The attribute is not required (L="" can have or not). So <C>abc</C><C L="A2">def</C> is not sure if A2 existed.
    *<!ELEMENT C (#PCDATA|D|E)*>*
    <!ELEMENT D (#PCDATA)>
    <!ELEMENT E EMPTY>
    this means :
    • between <C> </C> can have many ELEMENT E and E can be empty ( <E/> or <E> </E> ). So <C> <E/> <E> </E> </C> is correct.
    • <C><E><E/></E></C> is wrong beacause E is empty <E> </E> don't has anything.
    • between <C> </C> can have one or many ELEMENT D and D can be a text.beside ELEMENT C also have one or many beacause * . <C><D>abc</D></C><C>def</C is correct.
    • between <C> </C> can have Zero or More cause *
    http://www.w3schools.com/DTD/dtd_elements.asp
    Hello,

    I have an exam tomorrow, monday, and some help would be really appreciated >.<
    Given the following DTD : <!ELEMENT C (#PCDATA|D|E)>, what would be the corresponding schema, please?

    Thank you in advance for your response :)
  • SystemAdmin
    SystemAdmin
    1138 Posts

    Re: DTD validation

    ‏2011-02-27T14:02:29Z  
    Hello,

    I have an exam tomorrow, monday, and some help would be really appreciated >.<
    Given the following DTD : <!ELEMENT C (#PCDATA|D|E)>, what would be the corresponding schema, please?

    Thank you in advance for your response :)
    [0]
    Given the following DTD : <!ELEMENT C (#PCDATA|D|E)>
    This could never a valid DTD ELEMENT construction. With #PCDATA appearing in the first entry of the content model, it signifies it is of a mixed content type. With whatever D and E be constructed, the model need a cardinality of zero or more to be a valid DTD construction.
    
    <!ELEMENT C (#PCDATA|D|E)*>
    

    [1] With that in mind, and suppose D and E have a simple content (xs:string) type, it would appear like this in xsdl.
    
    <xs:element name=
    "C" type=
    "CType" /> <xs:element name=
    "D" type=
    "xs:string" /> <xs:element name=
    "E" type=
    "xs:string" /> <xs:complexType name=
    "CType" mixed=
    "true"> <xs:choice minOccurs=
    "0" maxOccurs=
    "unbounded"> <xs:element ref=
    "D" /> <xs:element ref=
    "E" /> </xs:choice> </xs:complexType>
    

    [1.1] If E is needed to be empty, just develop the content model for E to reflect the same. That does not change the overall structure.
  • SystemAdmin
    SystemAdmin
    1138 Posts

    Re: DTD validation

    ‏2011-02-27T14:09:09Z  
    sorry, my English is not good.But i will try. I also study XML _DTD _ SCHEMAS
    We see ELEMENT C :
    *<!ELEMENT C (#PCDATA|D|E)*>*
    this means :
    • between <C> and </C> can have a text or Element D or Element E.only one not all.So abc<C>cde<D>fgh</D></C> is wrong.
    • *(*#PCDATA|D|E*)** can have much more than a text or a Element D or a Element E. So <C>abc</C><C>fgh</C> is correct.

    <!ATTLIST C L IDREF #IMPLIED>
    this means :
    • <C L=""> </C> IDREF :The value is the id of another element(EX: ""> before ---> <C L=*"A2"*></C>).#IMPLIED :The attribute is not required (L="" can have or not). So <C>abc</C><C L="A2">def</C> is not sure if A2 existed.
    *<!ELEMENT C (#PCDATA|D|E)*>*
    <!ELEMENT D (#PCDATA)>
    <!ELEMENT E EMPTY>
    this means :
    • between <C> </C> can have many ELEMENT E and E can be empty ( <E/> or <E> </E> ). So <C> <E/> <E> </E> </C> is correct.
    • <C><E><E/></E></C> is wrong beacause E is empty <E> </E> don't has anything.
    • between <C> </C> can have one or many ELEMENT D and D can be a text.beside ELEMENT C also have one or many beacause * . <C><D>abc</D></C><C>def</C is correct.
    • between <C> </C> can have Zero or More cause *
    http://www.w3schools.com/DTD/dtd_elements.asp
    >between <C> and </C> can have a text or Element D or Element E.only one not all.So abc<C>cde<D>fgh</D></C> is wrong.
    I think that is not exact. This is perfectly fine,
    
    <C>cde<D>fgh</D></C>
    

    Even this is as well, etc...
    
    <C>cde<D>fgh</D>ijk<E />lmn<D>opq</D>rst</C>
    
  • SystemAdmin
    SystemAdmin
    1138 Posts

    Re: DTD validation

    ‏2011-02-27T16:17:24Z  
    [0]
    Given the following DTD : <!ELEMENT C (#PCDATA|D|E)>
    This could never a valid DTD ELEMENT construction. With #PCDATA appearing in the first entry of the content model, it signifies it is of a mixed content type. With whatever D and E be constructed, the model need a cardinality of zero or more to be a valid DTD construction.
    <pre class="jive-pre"> <!ELEMENT C (#PCDATA|D|E)*> </pre>
    [1] With that in mind, and suppose D and E have a simple content (xs:string) type, it would appear like this in xsdl.
    <pre class="jive-pre"> <xs:element name= "C" type= "CType" /> <xs:element name= "D" type= "xs:string" /> <xs:element name= "E" type= "xs:string" /> <xs:complexType name= "CType" mixed= "true"> <xs:choice minOccurs= "0" maxOccurs= "unbounded"> <xs:element ref= "D" /> <xs:element ref= "E" /> </xs:choice> </xs:complexType> </pre>
    [1.1] If E is needed to be empty, just develop the content model for E to reflect the same. That does not change the overall structure.
    Thank you :)