You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Schultz, Gary - COMM" <GS...@commerce.state.wi.us> on 2005/03/01 17:11:28 UTC
include specific element with cinclude
I have cinclude working so that I can get all of the specific elements from
an XML file. What I have not found a way to do is get the 2nd, 3rd, 4th,
etc. element or get an element by attribute value. I have found nothing in
Cocoon wiki to explain how one uses cinclude to include only a part of the
XML file.
For example, I can use the following to get all paragraph elements in an xml
file:
<cinclude:include xmlns:cinclude="http://apache.org/cocoon/include/1.0"
src="http://localhost/something.xml"
select="//*[local-name()='paragraph']/."/>
But what I want is to get a specific paragraph element from the file. Any
direction on this is greatly appreciated.
Gary T. Schultz
Web Technical Administrator / GIS Coordinator
Wisconsin Department of Commerce
6th Floor
P.O. Box 7970
Madison, WI
1-608-266-1283
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: include specific element with cinclude
Posted by Christoph Hermann <ch...@tu-clausthal.de>.
Schultz, Gary - COMM schrieb:
Hello,
> I have cinclude working so that I can get all of the specific
> elements from an XML file. What I have not found a way to do is get
> the 2nd, 3rd, 4th, etc. element or get an element by attribute value.
> I have found nothing in Cocoon wiki to explain how one uses cinclude
> to include only a part of the XML file.
>
> For example, I can use the following to get all paragraph elements in
> an xml file:
>
> <cinclude:include
> xmlns:cinclude="http://apache.org/cocoon/include/1.0"
> src="http://localhost/something.xml"
> select="//*[local-name()='paragraph']/."/>
>
> But what I want is to get a specific paragraph element from the file.
> Any direction on this is greatly appreciated.
You need to be more precise in your xpath expression:
//paragraph[@var='ABC123']
chooses all paragraphs with an attribute var that equals 'ABC123'.
paragraph[1]
chooses the first occurence of paragraph.
HTH
Christoph