Re: Keeping numeric entities intact when parsing and serializing?
by Petr Pajas other posts by this author
Oct 9 2009 9:17AM messages near this date
view in the new Beta List Site
Re: Keeping numeric entities intact when parsing and serializing?
|
Xpath problem?
& XSLT 2009/10/9 Nicolas Mendoza <mendoza@[...].no> :
> PÃ¥ Fri, 09 Oct 2009 17:54:39 +0200, skrev Nicolas Mendoza
> <mendoza@[...].no>:
>
> > Is there some way to keep the entities intact when parsing and
> > serlalizing
> > numeric entities?
Nicolas,
no, libxml2's APIs do not provide any such thing. The information
about which characters were encoded using entities and which not is
not made available by the XML parser.
Basically you can expect the following behavior from libxml2's (and
hence XML::LibXML's) serializer:
- if no encoding is specified for the document in the <?xml ...?>
declaration, any non-ascii character is encoded using an entity
- if an ecoding *is* specified for the document, then characters valid
for that encoding are serialized literally, whereas all "foreign"
characters (not representable in the given encoding) are serialized
using entities.
-- Petr
> > $ perl -wle 'use XML::LibXML; my $xml_parser = XML::LibXML->new(); my $d
> > =
> > $xml_parser->parse_string("<xml>Resolved: i Not resolved:
> > %amp;</xml>"); print $d->toString(); '
> > <?xml version="1.0"?>
> > <xml>Resolved: i Not resolved: %amp;</xml>
> >
>
> Sorry meant this:
>
> $ perl -wle 'use XML::LibXML; my $xml_parser = XML::LibXML->new(); my $d =
> $xml_parser->parse_string("<xml>Resolved: ' Not resolved:
> &</xml>"); print $d->toString(); '
> <?xml version="1.0"?>
> <xml>Resolved: ' Not resolved: &</xml>
>
> But same problem remains. Also I can't re-escape later I'm afraid.
>
> --
> Sendt med Operas revolusjonerende e-postprogram: http://www.opera.com/mail/
> _______________________________________________
> Perl-XML mailing list
> Perl-XML@[...].com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Nicolas Mendoza
Mirod
Jenda Krynicky
Nicolas Mendoza
Aristotle Pagaltzis
Nicolas Mendoza
Aristotle Pagaltzis
Petr Pajas
Nicolas Mendoza
Petr Pajas
Nicolas Mendoza
Aristotle Pagaltzis
Nicolas Mendoza
Nicolas Mendoza
Petr Pajas
|