sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
Gerald Aichholzer's Avatar

XSLT: looking help with XPath-expression


Question posted by: Gerald Aichholzer (Guest) on July 20th, 2005 09:41 AM
Hello NG,

I have a XML file looking like:

<!-- some elements here -->
<plugin>
<icon></icon>
<!-- some elements here -->
<object>
<!-- some elements here -->
</object>
<symbol>
<!-- some elements here -->
</symbol>
</plugin>


and I am looking for an XPath-Expression which selects
the following fragment (including attributes if present):

<plugin>
<icon></icon>
<!-- some elements here -->
<object>
<!-- some elements here -->
</object>
</plugin>

I know that I can select

. the attributes of <plugin> using
plugin/@*

. object and all subelements with attributes using
plugin/object/*|plugin/object/@*

. but how can I add only the direct childs of objects
with attributes?


thanx in advance,
Gerald
4 Answers Posted
Richard Tobin's Avatar
Richard Tobin July 20th, 2005 09:41 AM
Guest - n/a Posts
#2: Re: XSLT: looking help with XPath-expression

In article <429ad6c1$1@e-post.inode.at>,
Gerald Aichholzer <gary@sbox.tugraz.at> wrote:
[color=blue]
> <!-- some elements here -->
> <plugin>
> <icon></icon>
> <!-- some elements here -->
> <object>
> <!-- some elements here -->
> </object>
> <symbol>
> <!-- some elements here -->
> </symbol>
> </plugin>[/color]
[color=blue]
>and I am looking for an XPath-Expression which selects
>the following fragment (including attributes if present):
>
> <plugin>
> <icon></icon>
> <!-- some elements here -->
> <object>
> <!-- some elements here -->
> </object>
> </plugin>[/color]

You can't do that. XPath can only return nodes that are in the
original document, and you want a modified version of the <plugin>
element that only has some of the original children.

-- Richard
Martin Honnen's Avatar
Martin Honnen July 20th, 2005 09:41 AM
Guest - n/a Posts
#3: Re: XSLT: looking help with XPath-expression



Gerald Aichholzer wrote:

[color=blue]
> I have a XML file looking like:
>
> <!-- some elements here -->
> <plugin>
> <icon></icon>
> <!-- some elements here -->
> <object>
> <!-- some elements here -->
> </object>
> <symbol>
> <!-- some elements here -->
> </symbol>
> </plugin>
>
>
> and I am looking for an XPath-Expression which selects
> the following fragment (including attributes if present):
>
> <plugin>
> <icon></icon>
> <!-- some elements here -->
> <object>
> <!-- some elements here -->
> </object>
> </plugin>
>
> I know that I can select
>
> . the attributes of <plugin> using
> plugin/@*
>
> . object and all subelements with attributes using
> plugin/object/*|plugin/object/@*
>
> . but how can I add only the direct childs of objects
> with attributes?[/color]

plugin/object/* | plugin/object/@* | plugin/object/*/@*

--

Martin Honnen
http://JavaScript.FAQTs.com/
Gerald Aichholzer's Avatar
Gerald Aichholzer July 20th, 2005 09:41 AM
Guest - n/a Posts
#4: Re: XSLT: looking help with XPath-expression

Martin Honnen wrote:[color=blue]
>
>
> Gerald Aichholzer wrote:
>
>[color=green]
>> I have a XML file looking like:
>>
>> <!-- some elements here -->
>> <plugin>
>> <icon></icon>
>> <!-- some elements here -->
>> <object>
>> <!-- some elements here -->
>> </object>
>> <symbol>
>> <!-- some elements here -->
>> </symbol>
>> </plugin>
>>
>>
>> and I am looking for an XPath-Expression which selects
>> the following fragment (including attributes if present):
>>
>> <plugin>
>> <icon></icon>
>> <!-- some elements here -->
>> <object>
>> <!-- some elements here -->
>> </object>
>> </plugin>
>>
>> I know that I can select
>>
>> . the attributes of <plugin> using
>> plugin/@*
>>
>> . object and all subelements with attributes using
>> plugin/object/*|plugin/object/@*
>>
>> . but how can I add only the direct childs of objects
>> with attributes?[/color]
>
>
> plugin/object/* | plugin/object/@* | plugin/object/*/@*
>[/color]

Thank you, Martin.

Gerald
Richard Tobin's Avatar
Richard Tobin July 20th, 2005 09:41 AM
Guest - n/a Posts
#5: Re: XSLT: looking help with XPath-expression

In article <429af4d9$1@e-post.inode.at>,
Gerald Aichholzer <gary@sbox.tugraz.at> wrote:
[color=blue][color=green][color=darkred]
>>> <plugin>
>>> <icon></icon>
>>> <!-- some elements here -->
>>> <object>
>>> <!-- some elements here -->
>>> </object>
>>> </plugin>[/color][/color][/color]
[color=blue][color=green]
>> plugin/object/* | plugin/object/@* | plugin/object/*/@*[/color][/color]
[color=blue]
>Thank you, Martin.[/color]

That doesn't do what your example shows, but maybe it does what you
want.

-- Richard
 
Not the answer you were looking for? Post your question . . .
197,026 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 197,026 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors