ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-xml
perl-xml
Re: XML::Twig '0' PCDATA erased?
by Ken MacLeod other posts by this author
Jul 25 2000 12:47PM messages near this date
view in the new Beta List Site
XML::AutoWriter, XML::Filter::Validator? | XML::Parser errors
Michel Rodriguez <mrodrigu@[...].org>  writes:

>  On Tue, 25 Jul 2000, Tylman Ule wrote:
>  
>  > However, I came across the same problem pointed out by Jay J.
>  > Simplifying his code, I think the problem is, in a nutshell, that empty
>  > elements are treated as if they have a closing tag, and, as a result,
>  > their content appears to their right. The code below results in the
>  > following XML output:
>  
>  > my $doc = <<'_EOT_';
>  > <?xml version='1.0' standalone="yes"?>
>  > <document>
>  > <some_tag/>
>  > <some_tag></some_tag>
>  > </document>
>  > _EOT_
>  
>  This is illegal I think. I don't believe a tag can be both empty AND not
>  empty in the same document. I am surprised that Expat did not croak on it.

 3.1 Start-Tags, End-Tags, and Empty-Element Tags

  [...]

  If an element is empty, it must be represented either by a start-tag
  immediately followed by an end-tag or by an empty-element tag. An
  empty-element tag takes a special form:

  [...]

  Empty-element tags may be used for any element which has no content,
  whether or not it is declared using the keyword EMPTY. *For
  interoperability*, the empty-element tag must be used, and can only
  be used, for elements which are declared EMPTY.

[emphasis mine]

This reads to me that if you are validating (not Expat), and the
parser comes across a start-tag and end-tag pair for an element that
is declared EMPTY or an empty-element for an element that is not
declared EMPTY, then it should be reported as a warning.

A non-validating parser treats a empty start-tag/end-tag pair and an
empty-tag as effectively the same thing.  Expat, for example, calls
both the start-element and end-element callbacks.

In your message to xml-dev, you mention about an element having
content in one place and an empty-tag being used for the same element
in another place.  A validating parser would catch that as above but a
non-validating parser won't care.

  -- Ken

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved