xlink and xpointer

Discussion in 'XML' started by Martin, Feb 9, 2007.

  1. Martin

    Martin Guest

    Hello

    I'm trying to learn xlink/xpointer (with no success so far :-(

    I would like to produce the following output.

    AAAA
    BBBB
    CCCC
    AAAA
    BBBB
    DDDD

    In the xlst I have tried changing the xsl:for-each to see if
    I could figure out how to address the <test><Common><Param>
    With no success.
    Maybe the xlink I have done is wrong, or even what I like
    to achieve is not possible at all.


    The xml file I have is like this.

    <?xml version="1.0" encoding="iso-8859-1"?>
    <?xml-stylesheet type="text/xsl" href="testxlink.xslt"?>
    <test xmlns:xlink="http://www.w3.org/1999/xlink">
    <Common id="pre">
    <Param>AAAA</Param>
    <Param>BBBB</Param>
    </Common>

    <Element>
    <common xlink:type="simple" xlink:href="#pre"/>
    <Param>CCCC</Param>
    </Element>
    <Element>
    <common xlink:type="simple" xlink:href="#pre"/>
    <Param>DDDD</Param>
    </Element>
    </test>


    The xslt
    <?xml version="1.0" encoding="ISO-8859-1"?>

    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/">
    <xsl:for-each select="test/Element">
    <xsl:for-each select="Param">
    <xsl:value-of select="."/>
    </xsl:for-each>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>
    Martin, Feb 9, 2007
    #1
    1. Advertising

  2. If you want that output, you have to have logic that explicitly expands
    the XLink -- either in something that processes your file before the
    stylesheet sees it, or in the stylesheet itself. You haven't provided
    the latter, and apparently nothing in your system is providing the former.

    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
    Joe Kesselman, Feb 10, 2007
    #2
    1. Advertising

  3. Martin

    Martin Guest

    Joe Kesselman wrote:

    > If you want that output, you have to have logic that explicitly expands
    > the XLink -- either in something that processes your file before the
    > stylesheet sees it, or in the stylesheet itself. You haven't provided
    > the latter, and apparently nothing in your system is providing the former.
    >

    I see.

    I was hoping the xslt processor should expand the xlink (automatically),
    and then it was only a mather of seeing xml elements.
    Is there any xslt processor who will do the expansion automatically.

    /Martin
    Martin, Feb 10, 2007
    #3
  4. * Martin wrote in comp.text.xml:
    >Is there any xslt processor who will do the expansion automatically.


    No, for what you want XInclude http://www.w3.org/TR/xinclude/ is better
    suited. If you want to do this in XSLT you could just use the substring-
    after function to get the part after the # in the xlink:href and simply
    find the corresponding element and apply any transformation to that, or
    simply copy it using xsl:copy-of.
    --
    Björn Höhrmann · mailto: · http://bjoern.hoehrmann.de
    Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
    68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
    Bjoern Hoehrmann, Feb 10, 2007
    #4
  5. Martin

    Martin Guest

    Bjoern Hoehrmann wrote:

    > * Martin wrote in comp.text.xml:
    >>Is there any xslt processor who will do the expansion automatically.

    >
    > No, for what you want XInclude http://www.w3.org/TR/xinclude/ is better
    > suited. If you want to do this in XSLT you could just use the substring-
    > after function to get the part after the # in the xlink:href and simply
    > find the corresponding element and apply any transformation to that, or
    > simply copy it using xsl:copy-of.


    XInclude fantastic.

    I rewrote the xml and now it works as I like.

    many thanks
    /Martin


    <?xml version="1.0" encoding="iso-8859-1"?>
    <?xml-stylesheet type="text/xsl" href="testxlink.xslt"?>
    <test xmlns:xi="http://www.w3.org/2001/XInclude">
    <Common>
    <Param>AAAA</Param>
    <Param>BBBB</Param>
    </Common>

    <Element>
    <xi:include href="#xpointer(//Common/Param)"/>
    <Param>CCCC</Param>
    </Element>
    <Element>
    <xi:include href="#xpointer(//Common/Param)"/>
    <Param>DDDD</Param>
    </Element>
    </test>
    Martin, Feb 10, 2007
    #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. shay
    Replies:
    0
    Views:
    849
  2. tintagel

    using xpointer in html

    tintagel, Apr 1, 2006, in forum: HTML
    Replies:
    3
    Views:
    430
    tintagel
    Apr 3, 2006
  3. DV
    Replies:
    1
    Views:
    2,766
    Martin Honnen
    Apr 19, 2004
  4. Replies:
    0
    Views:
    489
  5. Robert Jones

    xlink and xpointer

    Robert Jones, Dec 2, 2007, in forum: XML
    Replies:
    3
    Views:
    473
    Joe Kesselman
    Dec 2, 2007
Loading...

Share This Page