← Prev in month ← Prev in thread

Can XML documents have loops (cycles)?

From
Costello, Roger L. <>
To
"" <>
Date
2011-10-10T12:03:52Z
ID
<>
Thread
Can XML documents have loops (cycles)?
Hi Folks,

Chris Burdess wrote:

> This is a representation of a cyclic graph in some vocabulary 
> not defined within the scope of XML, but the XML document 
> itself is not a cyclic graph, is it. My XML parser can parse the 
> XML just fine without having to worry about falling into an 
> infinite loop.

Below is an XML document. It conforms to the XML specification. It is well formed and valid. It's ID/IDREF values form a loop (cycle). The loop is formed using only stuff specified in the XML specification. 

So, why can't XML documents have loops (cycles)?  Why doesn't an XML parser have to worry about falling into an infinite loop? 

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Graph [
<!ELEMENT Graph (Node)+>
<!ELEMENT Node EMPTY>
<!ATTLIST Node
             id ID #REQUIRED
             idref IDREF #REQUIRED>
]>
<Graph>
    <Node id="_1" idref="_2" />
    <Node id="_2" idref="_1" />
</Graph>

/Roger
← Prev in month ← Prev in thread