Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Special character problem in DTD

Reply
Thread Tools

Special character problem in DTD

 
 
Aray
Guest
Posts: n/a
 
      12-15-2006
<!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

--



 
Reply With Quote
 
 
 
 
Bjoern Hoehrmann
Guest
Posts: n/a
 
      12-15-2006
* 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 '|'.
--
Bjrn Hhrmann (E-Mail Removed) 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/
 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      12-15-2006
In article <eltklr$250$(E-Mail Removed)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.
 
Reply With Quote
 
Peter Flynn
Guest
Posts: n/a
 
      12-15-2006
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/
 
Reply With Quote
 
Aray
Guest
Posts: n/a
 
      12-16-2006


--

"Peter Flynn" <(E-Mail Removed)> дϢ
news:(E-Mail Removed)...

> 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|r adioGroup|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.


 
Reply With Quote
 
Peter Flynn
Guest
Posts: n/a
 
      12-16-2006
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/
 
Reply With Quote
 
Aray
Guest
Posts: n/a
 
      12-18-2006


--

"Peter Flynn" <(E-Mail Removed)> дϢ
news:(E-Mail Removed)...
> 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/



 
Reply With Quote
 
Manuel Collado
Guest
Posts: n/a
 
      12-18-2006
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

 
Reply With Quote
 
Peter Flynn
Guest
Posts: n/a
 
      12-18-2006
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/
 
Reply With Quote
 
Aray
Guest
Posts: n/a
 
      12-19-2006
Thanks for your help.

I took Manuel Collado <(E-Mail Removed)> 's advise. using schema
to validate the xml

--

"Peter Flynn" <(E-Mail Removed)> дϢ
news:(E-Mail Removed)...


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XML file from one DTD to another DTD test Java 2 07-28-2006 08:48 PM
How to specify DTD to DTD.getDTD for DocumentParser? Ronald Fischer Java 4 03-17-2005 09:37 AM
Removing the dtd name when using print(...) on the dtd generated class Joseph Tilian Java 0 12-21-2004 02:58 PM
Including a dtd into another dtd... possible? Asfand Yar Qazi XML 1 09-19-2003 12:10 PM
Special character in dtd default attribute Ajay Goel XML 1 07-17-2003 07:51 AM



Advertisments