xlink and xpointer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martin

    #1

    xlink and xpointer

    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="ht tp://www.w3.org/1999/xlink">
    <Common id="pre">
    <Param>AAAA</Param>
    <Param>BBBB</Param>
    </Common>

    <Element>
    <common xlink:type="sim ple" xlink:href="#pr e"/>
    <Param>CCCC</Param>
    </Element>
    <Element>
    <common xlink:type="sim ple" xlink:href="#pr e"/>
    <Param>DDDD</Param>
    </Element>
    </test>


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

    <xsl:styleshe et 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>




  • Joe Kesselman

    #2
    Re: xlink and xpointer

    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

    Comment

    • Martin

      #3
      Re: xlink and xpointer

      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

      Comment

      • Bjoern Hoehrmann

        #4
        Re: xlink and xpointer

        * 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:bjoern@h oehrmann.de · 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/

        Comment

        • Martin

          #5
          Re: xlink and xpointer

          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>

          Comment

          Working...