escape colon in xml tag names

J

Jadow

Hi

I have an application that needs to handle non-xml characters in the
tag names such as a colon. I have not found how to escape this. I do
not want to reject the document but rather translate any characters
before building the xml. Uisng ISO codes does not work (& is not
acceptable in way in a tag name it seems). Ideally I would like to use
something like /: to escape whatever characters I need. Is there some
xml schema solutions I could use?

Thanks
Joshua
 
T

Toni Uusitalo

hi,

Jadow said:
Hi

I have an application that needs to handle non-xml characters in the
tag names such as a colon. I have not found how to escape this. I do
not want to reject the document but rather translate any characters
before building the xml. Uisng ISO codes does not work (& is not
acceptable in way in a tag name it seems). Ideally I would like to use
something like /: to escape whatever characters I need. Is there some
xml schema solutions I could use?

XML spec restricts name characters roughly to:

name start: letter | '_'
other: Letter | Digit | '.' | '-' | '_'

| means OR
Letter means unicode character

Colon ':' is reserved for namespace use (might be legal in name if
namespace awareness is turned off in xml parser)

So this leaves you two options:

- Use parser that isn't conformant to xml spec (or can be configured
to ignore name checking). I personally don't recommend this option -
non-conformant parsers can give you trouble - or if you must do this,
pick a parser that has common interface/that can be replaced with
conformant parser later.

- Fix your documents. Those characters are illegal in tag names. Use
regexps etc. if you must do lot of fixing.

p.s. schemas can't help you, they deal with validity of documents,
you're dealing with well-formedness issue with illegal tag names here.

with respect,
Toni Uusitalo
 

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