escape colon in xml tag names

Discussion in 'XML' started by Jadow, Jan 14, 2004.

  1. Jadow

    Jadow Guest

    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
     
    Jadow, Jan 14, 2004
    #1
    1. Advertising

  2. hi,

    "Jadow" <> wrote in message
    news:...
    > 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
     
    Toni Uusitalo, Jan 14, 2004
    #2
    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. shruds
    Replies:
    1
    Views:
    841
    John C. Bollinger
    Jan 27, 2006
  2. hoke

    tag to escape other tags

    hoke, Jan 29, 2004, in forum: HTML
    Replies:
    3
    Views:
    415
    Leif K-Brooks
    Jan 30, 2004
  3. Lewis G. Pringle, Jr.
    Replies:
    0
    Views:
    602
    Lewis G. Pringle, Jr.
    Sep 30, 2003
  4. Craig
    Replies:
    0
    Views:
    446
    Craig
    Feb 9, 2004
  5. slomo
    Replies:
    5
    Views:
    1,547
    Duncan Booth
    Dec 2, 2007
Loading...

Share This Page