By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,691 Members | 1,143 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,691 IT Pros & Developers. It's quick & easy.

xlink and xpointer

P: n/a
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>


Feb 10 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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
Feb 10 '07 #2

P: n/a
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
Feb 10 '07 #3

P: n/a
* 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:bj****@hoehrmann.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/
Feb 10 '07 #4

P: n/a
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>

Feb 11 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.