[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Is it possible to merge attributes from multiple element

Subject: Re: Is it possible to merge attributes from multiple elements?
From: Edwin Glaser <edwin@xxxxxxxxxxxxxxx>
Date: Sun, 18 Jun 2000 12:30:06 +0200
xslt merge attributes
You wrote:
> I'm trying to write a template that combines attributes from two elements into a 
> single element. The goal is to use XSLT to translate something like this:
> 
> <matrix>
>  <column c="1">
>  <column c="2">
>  <row r="1">
>  <row r="2">
> </matrix>
> 
> into something like this:
> 
> <table>
>  <tr><td c="1" r="1"/><td c="2" r="1"/></tr>
>  <tr><td c="1" r="2"/><td c="2" r="2"/></tr>
> </table>

> As far as I've been able to tell, variables, can't hold anything other than simple 
> text--much less a collection of attribute nodes.

Don't know if it is possible with pure xslt, but with a rtf->nodeset converter
your solution needs only slightly modifications. Here is a xalan example, saxon
has a builtin converter. Let's hope the next xslt specification will remove those
brain-dead limitations!

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns:util="de.pannenleiter.xmlapache.Util"
    exclude-result-prefixes="util"> 

<xsl:template match="row">
 <xsl:variable name="this"><xsl:copy-of select="."/></xsl:variable>
 <tr>
  <xsl:for-each select="../column">
  <td>
   <xsl:for-each select="@*">
    <xsl:copy/>
   </xsl:for-each>
   <xsl:for-each select="util:nodeset($this)/*/@*">
    <xsl:copy/>
   </xsl:for-each>
  </td>
 </xsl:for-each>
</tr>
</xsl:template>

</xsl:stylesheet>


public class Util 
{
  public static XNodeSet nodeset(Node value)
    throws Exception
  {
    Node node = (Node) value;
    return new XNodeSet((Node) value);
  }
}

Hope it helps, edwin

-- 
Edwin Glaser -- edwin@xxxxxxxxxxxxxxx


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.