cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geert Josten <>
Subject Re: include specific element with cinclude
Date Tue, 01 Mar 2005 18:06:52 GMT

> I've made various attempts to be more specific in the XPath and nothing
> works. I've tried the following:
> <cinclude:include xmlns:cinclude="" 
>   src="http://localhost/something.xml"
> select="//*[local-name()='paragraph[2]']/."/>

local-name() returns the name of the element without the namespace prefix. You added a predicate

test, but added it to the compare string for the local-name(). Move it to _after_ the original
bracket, like:


(you can drop the /. at the end)

This selects _every_ second paragraph within any parent that occurs.

> <cinclude:include xmlns:cinclude="" 
>   src="http://localhost/something.xml"
> select="//*[local-name()='page']/paragraph[2]"/>

This, for starters, requires that paragraph has element 'page' as parent.
Moreover, it looks for 'paragraph' elements without namespace.

> <cinclude:include xmlns:cinclude="" 
>   src="http://localhost/something.xml"
> select="//*[local-name()='page']/paragraph[2]/."/>

Does the same as previous..

> <cinclude:include xmlns:cinclude="" 
>   src="http://localhost/something.xml"
> select="//*[local-name()='page/paragraph[2]']/."/>

Again, you added the predicates to the compare string, that won't work

> <cinclude:include xmlns:cinclude="" 
>   src="http://localhost/something.xml"
> select="//*[local-name()='page']/paragraph/[2]"/>

Illegal XPath. You can't specify a predicated directly after a /. Add at least one dot between,
it is easier just to drop the /.. :-)

In short, you are looking for either:




Two additional notes:
* //paragraph[2] is not the same as (//paragraph)[2]
* Specify the namespace of paragraph in you XML that contains the cincludes and use the prefix
the select expressions. Matching through local-name() is not a good method.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message