Special character problem in DTD

A

Aray

<!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

--
 
B

Bjoern Hoehrmann

* 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 '|'.
 
R

Richard Tobin

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
 
P

Peter Flynn

Aray said:
<!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
 
A

Aray

--

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. :)
 
P

Peter Flynn

Aray said:
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
 
A

Aray

--

Peter Flynn said:
Aray said:
<!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
 
M

Manuel Collado

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.
 
P

Peter Flynn

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,007
Messages
2,570,266
Members
46,865
Latest member
AveryHamme

Latest Threads

Top