Can you use greater than character between tags?

P

Paddy3118

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

Paddy3118

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

Martin Honnen

Paddy3118 said:
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."
 
R

Richard Tobin

Paddy3118 said:
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
 
J

Joseph Kesselman

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

Paddy3118

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

Thanks for that link. Its a good resource!

- Paddy.
 
T

TreeStages

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/
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top