Can you use greater than character between tags?

Discussion in 'XML' started by Paddy3118, Dec 12, 2007.

  1. Paddy3118

    Paddy3118 Guest

    Hi,
    I am trying to find out if thhe following snippet would be valid XML
    - specifically the use of '>' between the tags:

    <expression> A>=B </expression>

    Should it be:

    <expression> A&gt;=B </expression>

    Could you also point me at an official spec reference about the issue?

    I ask because I was not expecting the first form and wasted time as it
    hid an error. If I pass the file through xmllint it spits out the
    second form but without giving an error.

    P.S. I'm a relative XML newby

    - Paddy.
     
    Paddy3118, Dec 12, 2007
    #1
    1. Advertising

  2. Paddy3118

    Paddy3118 Guest

    On 12 Dec, 15:12, Paddy3118 <> wrote:
    > Hi,
    > I am trying to find out if thhe following snippet would be valid XML
    > - specifically the use of '>' between the tags:
    >
    > <expression> A>=B </expression>
    >
    > Should it be:
    >
    > <expression> A&gt;=B </expression>
    >
    > Could you also point me at an official spec reference about the issue?
    >
    > I ask because I was not expecting the first form and wasted time as it
    > hid an error. If I pass the file through xmllint it spits out the
    > second form but without giving an error.
    >
    > P.S. I'm a relative XML newby
    >
    > - Paddy.


    A little extra searching and I have found the relevant information, it
    is allowed!

    http://www.w3.org/TR/2006/REC-xml-20060816/#syntax

    - Paddy.
     
    Paddy3118, Dec 12, 2007
    #2
    1. Advertising

  3. Paddy3118 wrote:
    > Hi,
    > I am trying to find out if thhe following snippet would be valid XML
    > - specifically the use of '>' between the tags:
    >
    > <expression> A>=B </expression>


    It is well-formed XML. You only need to escape the less-than sign '<' as
    '&lt;' and the ampersand '&' as '&amp;'. The greater-than sign does not
    need to be escaped.


    > Could you also point me at an official spec reference about the issue?


    See <URL:http://www.w3.org/TR/REC-xml/#syntax> which says: "The
    ampersand character (&) and the left angle bracket (<) MUST NOT appear
    in their literal form, except when used as markup delimiters, or within
    a comment, a processing instruction, or a CDATA section. If they are
    needed elsewhere, they MUST be escaped using either numeric character
    references or the strings "&amp;" and "&lt;" respectively."

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Dec 12, 2007
    #3
  4. In article <>,
    Paddy3118 <> wrote:

    >I am trying to find out if thhe following snippet would be valid XML
    >- specifically the use of '>' between the tags:


    This is allowed except for the special case of ]]> which is only
    allowed as the end of a CDATA section.

    So you can't say

    <code>if(a[b[x]]>2) ...</code>

    but that doesn't happen very often.

    -- Richard
    --
    :wq
     
    Richard Tobin, Dec 12, 2007
    #4
  5. Martin Honnen wrote:
    >> I am trying to find out if thhe following snippet would be valid XML
    >> - specifically the use of '>' between the tags:


    Same section of the spec, next sentence:

    "The right angle bracket (>) may be represented using the string "&gt;",
    and MUST, for compatibility, be escaped using either "&gt;" or a
    character reference when it appears in the string "]]>" in content, when
    that string is not marking the end of a CDATA section."

    Many tools will accept the floating > without requiring that it be
    escaped, since the intended meaning is obvious. But some may not, hence
    the recommendation to always escape it.

    For more info on why this decision was made, look at the footnotes in
    the Annotated XML Spec (http://www.xml.com/axml/testaxml.htm) -- a
    wonderful resource for understanding why XML is as it is and what the
    less obvious phrases were actually intended to mean. (Alas, Tim Bray has
    not had time to update this for the 1.1 version of the recommendation,
    but most of it remains correct and his comments are still hugely useful.)



    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
     
    Joseph Kesselman, Dec 12, 2007
    #5
  6. Paddy3118

    Paddy3118 Guest

    On Dec 12, 3:56 pm, Joseph Kesselman <>
    wrote:
    > Martin Honnen wrote:
    > >> I am trying to find out if thhe following snippet would be valid XML
    > >> - specifically the use of '>' between the tags:

    >
    > Same section of the spec, next sentence:
    >
    > "The right angle bracket (>) may be represented using the string "&gt;",
    > and MUST, for compatibility, be escaped using either "&gt;" or a
    > character reference when it appears in the string "]]>" in content, when
    > that string is not marking the end of a CDATA section."
    >
    > Many tools will accept the floating > without requiring that it be
    > escaped, since the intended meaning is obvious. But some may not, hence
    > the recommendation to always escape it.
    >
    > For more info on why this decision was made, look at the footnotes in
    > the Annotated XML Spec (http://www.xml.com/axml/testaxml.htm) -- a
    > wonderful resource for understanding why XML is as it is and what the
    > less obvious phrases were actually intended to mean. (Alas, Tim Bray has
    > not had time to update this for the 1.1 version of the recommendation,
    > but most of it remains correct and his comments are still hugely useful.)
    >
    > --
    > Joe Kesselman / Beware the fury of a patient man. -- John Dryden


    Thanks for that link. Its a good resource!

    - Paddy.
     
    Paddy3118, Dec 13, 2007
    #6
  7. Paddy3118

    TreeStages Guest

    On Dec 12, 10:12 am, Paddy3118 <> wrote:
    > Hi,
    > I am trying to find out if thhe following snippet would be valid XML
    > - specifically the use of '>' between the tags:
    >
    > <expression> A>=B </expression>


    This is a valid (well-formed) xml.
    You can find the syntax of xml character data at w3.org site, or
    you can download our XEntrant tool from our site, and use
    Help->NodeHelp->GeneralInfo baloons to see the syntax of
    individual xml tree components.

    http://www.treestages.com/
     
    TreeStages, Dec 14, 2007
    #7
    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. danthman
    Replies:
    2
    Views:
    2,356
    danthman
    Dec 23, 2005
  2. falcon
    Replies:
    10
    Views:
    18,699
    Roedy Green
    Feb 24, 2006
  3. jackie
    Replies:
    2
    Views:
    2,031
    E. R. Jacobson
    Jan 7, 2005
  4. RC
    Replies:
    6
    Views:
    1,691
    Mike Schilling
    Dec 14, 2006
  5. Dwight Army of Champions
    Replies:
    4
    Views:
    2,758
    John H.
    Mar 17, 2010
Loading...

Share This Page