invalid characters in tag name

J

jc

Hi, I want to build a xml translation map as the following

<A english sentence, with punctuations such as "?">translation of this
sentence in some language in utf8 </A english sentence, with
punctuations such as "?">

My question
1) is there a standard way doing what I want to do?
2) if not, then how do I escape the possible "," and "?" in the
sentence in the tag name? because "&" is not allowed in tag name
either

Thanks in advacne
 
K

Kenneth Stephen

jc said:
Hi, I want to build a xml translation map as the following

<A english sentence, with punctuations such as "?">translation of this
sentence in some language in utf8 </A english sentence, with
punctuations such as "?">

My question
1) is there a standard way doing what I want to do?
2) if not, then how do I escape the possible "," and "?" in the
sentence in the tag name? because "&" is not allowed in tag name
either
Hi,

Whitespace isnt allowed either in a tag name. I dont believe there is a
way to escape any of the illegal characters. Your question indicates,
though, that you are misapplying XML concepts. The "sentence" you are
dealing with is "data" and you are attempting to put it into "markup". The
two should never mix - that is the whole point of having a markup language.
Perhaps you can describe what problem you are trying to solve?

Regards,
Kenneth
 
C

Chris Lovett

<?xml version='1.0' encoding='utf-8'?>
<A>
<A1 xml:lang="en">english sentence, with punctuations such as "?"</A1>
<A2 xml:lang="whatever">of this sentence in some language </A1>
</A>

Don't confuse language and encoding (utf-8). The encoding applies to the
entire file and UTF-8 is a fine choice and can encode any unicode
characters, which means any language.

The only characters that need to be escaped in XML text as shown above are
"<" and "&". Write these as the character entities "&lt;" and "&amp;"
respectiviely and you should be fine.
 
J

jc

I want to have translation for different languages. so russian.xml will
have <my_sentence>russian sentence</my_sentence>; and chinese.xml will
have <my_sentence>chinese sentence</my_sentence>, etc. The xml file will
be parsed at loading time and proper translated message will be
displayed at run time. I am trying to use the english as the lookup key
for its equivalent translation. the "sentence" is data, but here it is
more of just a key to the the real data. Is there a way to tell parser
not to parse the tagname, something like <CDATA>? Or may be xml is just
the format for doing what I want to do.
 
K

Kenneth Stephen

jc said:
I want to have translation for different languages. so russian.xml will
have <my_sentence>russian sentence</my_sentence>; and chinese.xml will
have <my_sentence>chinese sentence</my_sentence>, etc. The xml file will
be parsed at loading time and proper translated message will be
displayed at run time. I am trying to use the english as the lookup key
for its equivalent translation. the "sentence" is data, but here it is
more of just a key to the the real data. Is there a way to tell parser
not to parse the tagname, something like <CDATA>? Or may be xml is just
the format for doing what I want to do.
Hi,

Wont the following work for you :

<sentence lang="ru">Russian sentence</sentence>
<sentence lang="zh">Chinese sentence</sentence>

...or alternatively :

<sentence>
<lang>ru</lang>
<text>Russian sentence</text>
</sentence>
<sentence>
<lang>zh</lang>
<text>Chinese sentence</text>
</sentence>

...or

<sentence>
<lang name="ru">Russian sentence</lang>
<lang name="zh">Chinese sentence</lang>
</sentence>

I'm sure, with a bit more effort, you can think up a few more
combinations. None of the above solutions require any sort of "escaping"
because the tags are markup and dont mix with the data that you are
interested in.

Regards,
Kenneth
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top