XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Markus schmidtSubject: Hard Problem in XSLT
Author: Markus schmidt
Date: 08 Jun 2006 05:33 AM
hello all,

i have got a big problem, which I haven't resolved yet.

I have to transform from one xml file to another, but it seems that xsl(t) is not able to resolve my transformations.
i have got following xml-source (explanatory):

<table name="table1" schema="schema1"/>
<table name="table2" schema="schema2"/>
<table name="table3" schema="schema1"/>
<table name="table4" schema="schema1"/>


the output should be:

<Schema name="schema1" tables="table1 table3 table4"/>
<Schema name="schema2" tables="table2"/>

How to transform this kind of structure
1. without depending of any xslt-processor
2. and do the step in one transformation!
(not two xsl transformation files)

cheers for any response.
I am desparate with that problem..

Posttop
Minollo I.Subject: Hard Problem in XSLT
Author: Minollo I.
Date: 08 Jun 2006 10:13 AM
It's the usual XSLT grouping problem; you may want to search the forum for more help:

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

<xsl:key name="tables" match="//table" use="@schema"/>

<xsl:template match="/">
<root>
<xsl:for-each select="//table[generate-id() = generate-id(key('tables', @schema)[1])]">
<xsl:variable name="tableName" select="@schema"/>
<schema name="{$tableName}">
<xsl:attribute name="tables">
<xsl:for-each select="//table[@schema = $tableName]">
<xsl:value-of select="@name"/><xsl:text> </xsl:text>
</xsl:for-each>
</xsl:attribute>
</schema>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.