XSLT: looking help with XPath-expression

Discussion in 'XML' started by Gerald Aichholzer, May 30, 2005.

  1. 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
     
    Gerald Aichholzer, May 30, 2005
    #1
    1. Advertising

  2. In article <429ad6c1$>,
    Gerald Aichholzer <> wrote:

    > <!-- 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>


    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
     
    Richard Tobin, May 30, 2005
    #2
    1. Advertising

  3. Gerald Aichholzer wrote:


    > 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?


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

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, May 30, 2005
    #3
  4. Martin Honnen wrote:
    >
    >
    > Gerald Aichholzer wrote:
    >
    >
    >> 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?

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


    Thank you, Martin.

    Gerald
     
    Gerald Aichholzer, May 30, 2005
    #4
  5. In article <429af4d9$>,
    Gerald Aichholzer <> wrote:

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


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


    >Thank you, Martin.


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

    -- Richard
     
    Richard Tobin, May 30, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marvin_123456

    "Memory leak" in javax.xml.xpath.XPath

    Marvin_123456, Jul 29, 2005, in forum: Java
    Replies:
    4
    Views:
    1,976
    jan V
    Jul 29, 2005
  2. Alastair Cameron
    Replies:
    1
    Views:
    7,417
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  3. GIMME
    Replies:
    3
    Views:
    11,973
    vforvikash
    Dec 29, 2008
  4. Ralph Snart

    XSLT/XPath help

    Ralph Snart, Jun 7, 2005, in forum: XML
    Replies:
    2
    Views:
    455
    Dimitre Novatchev
    Jun 7, 2005
  5. Oleg Paraschenko
    Replies:
    3
    Views:
    487
    Stefan Ram
    Jul 28, 2006
Loading...

Share This Page