Special character problem in DTD

Discussion in 'XML' started by Aray, Dec 15, 2006.

  1. Aray

    Aray Guest

    <!ENTITY % testEntity "(test)">
    <!ELEMENT testElement %testEntity;>

    Above is a valid DTD file. But it doesn't work when I try to put a charater
    '/' in to the Content of testEntity. like following

    <!ENTITY % testEntity "(test/test)">
    <!ELEMENT testElement %testEntity;>

    I am newbie to xml, Could you please tell me how to make it works?

    Thanks

    --
     
    Aray, Dec 15, 2006
    #1
    1. Advertising

  2. * Aray wrote in comp.text.xml:
    ><!ENTITY % testEntity "(test)">
    ><!ELEMENT testElement %testEntity;>
    >
    >Above is a valid DTD file. But it doesn't work when I try to put a charater
    >'/' in to the Content of testEntity. like following
    >
    ><!ENTITY % testEntity "(test/test)">
    ><!ELEMENT testElement %testEntity;>
    >
    >I am newbie to xml, Could you please tell me how to make it works?


    You should review why you want to put the '/' there, perhaps
    you confuse it with some other character like ',' or '|'.
    --
    Björn Höhrmann · mailto: · http://bjoern.hoehrmann.de
    Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
    68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
     
    Bjoern Hoehrmann, Dec 15, 2006
    #2
    1. Advertising

  3. In article <eltklr$250$99.com>, Aray <1@2.3> wrote:

    >Above is a valid DTD file. But it doesn't work when I try to put a charater
    >'/' in to the Content of testEntity. like following
    >
    ><!ENTITY % testEntity "(test/test)">
    ><!ELEMENT testElement %testEntity;>
    >
    >I am newbie to xml, Could you please tell me how to make it works?


    It's got nothing to do with entities. It doesn't work for the same
    reason that

    <!ELEMENT testElement (test/test)>

    doesn't work. What are you trying to achieve?

    -- Richard
    --
    "Consideration shall be given to the need for as many as 32 characters
    in some alphabets" - X3.4, 1963.
     
    Richard Tobin, Dec 15, 2006
    #3
  4. Aray

    Peter Flynn Guest

    Aray wrote:
    > <!ENTITY % testEntity "(test)">
    > <!ELEMENT testElement %testEntity;>
    >
    > Above is a valid DTD file. But it doesn't work when I try to put a charater
    > '/' in to the Content of testEntity. like following
    >
    > <!ENTITY % testEntity "(test/test)">
    > <!ELEMENT testElement %testEntity;>
    >
    > I am newbie to xml, Could you please tell me how to make it works?


    Can you please tell us what you want to do (why you think you want to do
    this)?

    ///Peter
    --
    XML FAQ: http://xml.silmaril.ie/
     
    Peter Flynn, Dec 15, 2006
    #4
  5. Aray

    Aray Guest

    --

    "Peter Flynn" <> дÈëÏûÏ¢
    news:...

    > Can you please tell us what you want to do (why you think you want to do
    > this)?


    In HTML, we offten see the following line:

    <form enctype="multipart/form-data" >

    the attribute enctype can be "multipart/form-data",
    "application/x-www-form-urlencoded" or "text/plain"

    I want use XML to describe the FORM tag of HTML, and I want to make sure the
    enctype have valid value, so a DTD file with following line is needed:

    <!ENTITY % Enctype
    "(application/x-www-form-urlencoded|multipart/form-data|text/plain)">

    <!ELEMENT form
    (button|checkBoxGroup|file|hidden|image|password|radioGroup|reset|submit|text|select|textArea)*>
    <!ATTLIST form name CDATA #IMPLIED
    action CDATA #REQUIRED
    method (get|post) #REQUIRED
    enctype %Enctype; #IMPLIED>

    Then, I got the probelm, I can't put the character '/' in there.

    Thank you all to reply. :)
     
    Aray, Dec 16, 2006
    #5
  6. Aray

    Peter Flynn Guest

    Aray wrote:

    > In HTML, we offten see the following line:
    >
    > <form enctype="multipart/form-data" >
    >
    > the attribute enctype can be "multipart/form-data",
    > "application/x-www-form-urlencoded" or "text/plain"
    >
    > I want use XML to describe the FORM tag of HTML, and I want to make sure the
    > enctype have valid value, so a DTD file with following line is needed:
    >
    > <!ENTITY % Enctype
    > "(application/x-www-form-urlencoded|multipart/form-data|text/plain)">


    Ah, OK. Sorry for the misunderstanding: I thought you were trying to
    represent elements in a content model.

    Unfortunately you can't do that in XML: the values in Token Lists must
    be Names (see the XML Specification, production [5]). Name characters
    do not include the slash.

    > Then, I got the probelm, I can't put the character '/' in there.


    Correct. You can work around this using a Notation:

    <!NOTATION mime SYSTEM "http://www.iana.org/assignments/media-types/">
    <!ENTITY urlenc SYSTEM "application/x-www-form-urlencoded" NDATA mime>
    <!ENTITY formdata SYSTEM "multipart/form-data" NDATA mime>
    <!ENTITY plain SYSTEM "text/plain" NDATA mime>

    <!ELEMENT form (#PCDATA)>
    <!ATTLIST form name CDATA #IMPLIED
    action CDATA #REQUIRED
    method (get|post) #REQUIRED
    enctype ENTITY #IMPLIED>

    This makes the valid values for enctype one of urlenc, formdata, and
    plain (or whatever you choose to declare them as). An XSLT processor can
    then use the XPath function unparsed-entity-uri() to return the string
    value of the declared entities.

    ///Peter
    --
    XML FAQ: http://xml.silmaril.ie/
     
    Peter Flynn, Dec 16, 2006
    #6
  7. Aray

    Aray Guest

    --

    "Peter Flynn" <> дÈëÏûÏ¢
    news:...
    > Aray wrote:
    >> <!ENTITY % Enctype
    >> "(application/x-www-form-urlencoded|multipart/form-data|text/plain)">

    >
    > Ah, OK. Sorry for the misunderstanding: I thought you were trying to
    > represent elements in a content model.
    >
    > Unfortunately you can't do that in XML: the values in Token Lists must
    > be Names (see the XML Specification, production [5]). Name characters
    > do not include the slash.
    >
    >> Then, I got the probelm, I can't put the character '/' in there.

    >
    > Correct. You can work around this using a Notation:
    >
    > <!NOTATION mime SYSTEM "http://www.iana.org/assignments/media-types/">
    > <!ENTITY urlenc SYSTEM "application/x-www-form-urlencoded" NDATA mime>
    > <!ENTITY formdata SYSTEM "multipart/form-data" NDATA mime>
    > <!ENTITY plain SYSTEM "text/plain" NDATA mime>
    >
    > <!ELEMENT form (#PCDATA)>
    > <!ATTLIST form name CDATA #IMPLIED
    > action CDATA #REQUIRED
    > method (get|post) #REQUIRED
    > enctype ENTITY #IMPLIED>
    >
    > This makes the valid values for enctype one of urlenc, formdata, and plain
    > (or whatever you choose to declare them as). An XSLT processor can then
    > use the XPath function unparsed-entity-uri() to return the string value of
    > the declared entities.
    >


    Thanks for your replay.

    What I want is this: someone can write a xml file with this line: <form
    name="" action="" method="get" enctype="text/plain">
    the atribute enctype's value can only be one of the three:
    "application/x-www-form-urlencoded", "multipart/form-data" and "text/plain".

    But in solution above, enctype's value can be ony ENTITY defined in my DTD
    file(I do define some other ENTITY in the DTD file). how to restrict the
    value of enctype can ony be one of the three?

    Thanks

    > ///Peter
    > --
    > XML FAQ: http://xml.silmaril.ie/
     
    Aray, Dec 18, 2006
    #7
  8. Aray escribió:
    > Thanks for your replay.
    >
    > What I want is this: someone can write a xml file with this line: <form
    > name="" action="" method="get" enctype="text/plain">
    > the atribute enctype's value can only be one of the three:
    > "application/x-www-form-urlencoded", "multipart/form-data" and "text/plain".
    >
    > But in solution above, enctype's value can be ony ENTITY defined in my DTD
    > file(I do define some other ENTITY in the DTD file). how to restrict the
    > value of enctype can ony be one of the three?


    Perhaps Schematron could help.

    Regards.
    --
    To reply by e-mail, please remove the extra dot
    in the given address: m.collado -> mcollado
     
    Manuel Collado, Dec 18, 2006
    #8
  9. Aray

    Peter Flynn Guest

    Aray wrote:
    [...]
    > Thanks for your reply.
    >
    > What I want is this: someone can write an xml file with this line:
    > <form name="" action="" method="get" enctype="text/plain">
    > the attribute enctype's value can only be one of the three:
    > "application/x-www-form-urlencoded", "multipart/form-data" and "text/plain".


    No. I've already explained that you can't do this in XML. Read the XML
    Specification, production [5], as recommended. The slash is not
    permitted in token lists.

    > But in solution above, enctype's value can be only ENTITY defined in
    > my DTD file (I do define some other ENTITY in the DTD file). how to
    > restrict the value of enctype can ony be one of the three?


    Only the names of unparsed (data) declared entities (identified by a
    Notation) can be used as the value of a token list attribute, so unless
    you are declaring other unparsed entities, the value can only be one of
    those you declare. General entities cannot be used (see the Validity
    Constraint "Entity Name" to production [56] in the XML Specification).

    ///Peter
    --
    XML FAQ: http://xml.silmaril.ie/
     
    Peter Flynn, Dec 18, 2006
    #9
  10. Aray

    Aray Guest

    Thanks for your help.

    I took Manuel Collado <> 's advise. using schema
    to validate the xml

    --

    "Peter Flynn" <> дÈëÏûÏ¢
    news:...
     
    Aray, Dec 19, 2006
    #10
  11. Aray

    Aray Guest

    --

    "Manuel Collado" <> ????
    news:...
    > Perhaps Schematron could help.


    Thanks, I study around Schema for few hours, It does work!

    Thank you
     
    Aray, Dec 19, 2006
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Q2FuZGlkdXM=?=

    Problem with special character

    =?Utf-8?B?Q2FuZGlkdXM=?=, Aug 24, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    357
    =?Utf-8?B?Q2FuZGlkdXM=?=
    Aug 24, 2004
  2. Joseph Tilian
    Replies:
    0
    Views:
    362
    Joseph Tilian
    Dec 21, 2004
  3. Ronald Fischer
    Replies:
    4
    Views:
    1,773
    Ronald Fischer
    Mar 17, 2005
  4. Ajay Goel
    Replies:
    1
    Views:
    1,247
    Johannes Koch
    Jul 17, 2003
  5. test
    Replies:
    2
    Views:
    2,094
    Oliver Wong
    Jul 28, 2006
Loading...

Share This Page