Re: [xslt] Intermittent problem.
- From: Daniel Veillard <veillard redhat com>
- To: xslt gnome org
- Subject: Re: [xslt] Intermittent problem.
- Date: Sat, 24 Aug 2002 13:08:50 -0400
On Sat, Aug 24, 2002 at 06:50:25PM +0200, Le grande pinguin wrote:
> BTW, the stylesheet you posted is pretty "fragile":
>
> <xsl:if test="count(child::text()) = 1">
>
> is a rather dangerous test iff you use it to test whether a
> node has children. Even if the node doesn't have a child node,
> as soon as it contains an entity (internal or external) the
> test will fail. The following document:
>
> |
> | <!DOCTYPE doc [
> | <!ENTITY test "a sample as well as ">
> | ] >
> | <doc>This is &test; a test</doc>
> |
> get's parsed into this tree:
>
> |
> | ralf@calvin:/tmp$ xmllint --debug a.xml
> | DOCUMENT
> | version=1.0
> | URL=a.xml
> | standalone=true
> | DTD(doc)
> | ENTITYDECL(test), internal
> | content=a sample as well as
> | TEXT
> | content=a sample as well as
> | ELEMENT doc
> | TEXT
> | content=This is
> | ENTITY_REF(test)
> | INTERNAL_GENERAL_ENTITY test
> | content=a sample as well as
> | TEXT
> | content= a test
>
> where the doc node has 2(!) text children.
Well, actually for XPath processing entities are substitued and
there will be a single text node child as when using xmllint --noent
paphio:~/XML -> xmllint --noent --debug tst2.xml
DOCUMENT
version=1.0
URL=tst2.xml
standalone=true
DTD(doc)
ENTITYDECL(test), internal
content=a sample as well as
TEXT
content=a sample as well as
PBM: Node has no next and not last of list
ELEMENT doc
TEXT
content=This is a sample as well as a test
paphio:~/XML ->
xsltproc switch on entity substitution automatically,
Daniel
--
Daniel Veillard | Red Hat Network https://rhn.redhat.com/
veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]