This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Is this valid XML ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Is this valid XML ?" Watch "Is this valid XML ?" New topic
Author

Is this valid XML ?

nirjari patel
Ranch Hand

Joined: Apr 23, 2009
Posts: 363
following snippet is taken from workflow pdf manual ts.670.wf.pdf , page 62. Its a TeamSite development manual.




in this snippet, root element is 'template_script' but then again there is another 'workflow' element. so how there be an element outside root element ? As per xml syntax rules , all the elements have to be within root elemrnt only.

Can we have a code or CDATA anywhere in the xml doc ? inside or outside root element ? If I put a code at the beginning of the document as follows is it allowed ?



Please explain this syntax about elements outside root element.

thanks
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12756
    
    5
1. No elements can exist outside the root element, trailing elements will probably be ignored by parsers.
2. Starting with any tag except <?xml will probably lead to an error although parsers may tolerate a document that starts with the root element - as you would discover by trying it. Even a single leading space will cause a parser error.

3. Hiding XML inside CDATA can lead to mysterious and hard to find bugs.

Bill
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Is this valid XML ?
 
Similar Threads
Let's spin a yarn
XML Query
some notes on xml
Why b.c.d is correct?
at org.apache.myfaces.tomahawk.application.jsp.JspTilesTwoViewHandlerImpl.getServletMapping