xlink and xpointer

M

Martin

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

Joe Kesselman

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.
 
M

Martin

Joe said:
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
 
B

Bjoern Hoehrmann

* 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.
 
M

Martin

Bjoern said:
* Martin wrote in comp.text.xml:

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top