I will add it. It was someone else's idea so I didn't want to step on any
toes. Thought I'd check first.

-----Original Message-----
From: Derek Hohls [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 02, 2005 12:46 AM
To: users@cocoon.apache.org
Subject: RE: include specific element with cinclude


open a new wiki page and add it in!
(that's why its called a 'wiki' ;-)

>>> [EMAIL PROTECTED] 2005/03/01 08:16:28 PM >>>
Thank you, select="//*[local-name()='paragraph'][2]" worked. Makes
sense
now. This also works when using xpointer. This helps greatly. What
Geert
described needs to be in the wiki. How does one get this added?


-----Original Message-----
From: Geert Josten [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 01, 2005 12:07 PM
To: users@cocoon.apache.org 
Subject: Re: include specific element with cinclude



> I've made various attempts to be more specific in the XPath and
nothing
> works. I've tried the following:
> 
> <cinclude:include
xmlns:cinclude="http://apache.org/cocoon/include/1.0"; 
>   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 close 
bracket, like:

select="//*[local-name()='paragraph'][2]"

(you can drop the /. at the end)

This selects _every_ second paragraph within any parent that occurs.

> <cinclude:include
xmlns:cinclude="http://apache.org/cocoon/include/1.0"; 
>   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="http://apache.org/cocoon/include/1.0"; 
>   src="http://localhost/something.xml";
> select="//*[local-name()='page']/paragraph[2]/."/>

Does the same as previous..

> <cinclude:include
xmlns:cinclude="http://apache.org/cocoon/include/1.0"; 
>   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="http://apache.org/cocoon/include/1.0"; 
>   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, but 
it is easier just to drop the /.. :-)

In short, you are looking for either:

//*[local-name()='paragraph'][2]

or

//*[local-name()='page']/*[local-name()='paragraph'][2]

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 in 
the select expressions. Matching through local-name() is not a good
method.

Cheers,
Geert

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to