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
misha tsvetSubject: Same name and different property in xml
Author: misha tsvet
Date: 07 Jun 2006 01:21 PM
There is such problem here is xml:
<records>
<record>
<SRC_URL>http://www.j2mepolish.org/devices/Alcatel/One_Touch_735i.html</SRC_URL>
<DATES>2006-06-06 17:25:40</DATES>
<PHONE_NAME>Alcatel</PHONE_NAME>
<MODELS>One_Touch_735i</MODELS>
<PROPERTY>Screen-Size (width x height)</PROPERTY>
<VALUE1>128x128</VALUE1>
</record>
<record>
<SRC_URL>http://www.j2mepolish.org/devices/Alcatel/One_Touch_735i.html</SRC_URL>
<DATES>2006-06-06 17:25:40</DATES>
<PHONE_NAME>Alcatel</PHONE_NAME>
<MODELS>One_Touch_735i</MODELS>
<PROPERTY>Bits per Pixel</PROPERTY>
<VALUE1>12
(4,096 colors)</VALUE1>
</record>
</records>

I get with XSLT:

<device-list>
<device manufacturer="Alcatel" name="One_Touch_735i" src-url="http://www.j2mepolish.org/devices/Alcatel/One_Touch_735i.html" retrieval-time="2006-06-07 13:33:40">
<property name="Screen-Size (width x height)" value="128x128"/>
</device>
<device manufacturer="Alcatel" name="One_Touch_735i" src-url="http://www.j2mepolish.org/devices/Alcatel/One_Touch_735i.html" retrieval-time="2006-06-07 13:33:40">
<property name="Bits per Pixel" value="12 (4,096 colors)"/>
</device>
</device-list>

With a help of such code:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="records">
<device-list>
<xsl:for-each select="record">
<device>
<xsl:attribute name="manufacturer"><xsl:value-of select="PHONE_NAME"/></xsl:attribute>
<xsl:attribute name="name"><xsl:value-of select="MODELS"/></xsl:attribute>
<xsl:attribute name="src-url"><xsl:value-of select="SRC_URL"/></xsl:attribute>
<xsl:attribute name="retrieval-time"><xsl:value-of select="DATES"/></xsl:attribute>
<property>
<xsl:attribute name="name"><xsl:value-of select="PROPERTY"/></xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="VALUE1"/></xsl:attribute>
</property>
</device>
</xsl:for-each>
</device-list>
</xsl:template>
</xsl:stylesheet>

But i must get this:

<device-list>
<device manufacturer="Alcatel" name="One_Touch_735i" src-url="http://www.j2mepolish.org/devices/Alcatel/One_Touch_735i.html" retrieval-time="2006-06-07 13:33:40">
<property name="Screen-Size (width x height)" value="128x128"/>
<property name="Bits per Pixel" value="12 (4,096 colors)"/>
</device>
</device-list>
Can anybody help me to do this?

Postnext
Minollo I.Subject: Same name and different property in xml
Author: Minollo I.
Date: 07 Jun 2006 01:41 PM
Something like this? You may have to change the "concat" function to get the proper grouping logic.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="records" match="records/record" use="concat(SRC_URL, DATES, PHONE_NAME, MODELS)"/>
<xsl:template match="/">
<device-list>
<xsl:for-each select="/records/record[generate-id() = generate-id(key('records', concat(SRC_URL, DATES, PHONE_NAME, MODELS))[1])]">
<device manufacturer="{PHONE_NAME}" name="{MODELS}" src-url="{SRC_URL}" retrieval-time="{DATES}">
<xsl:variable name="keyVal" select="concat(SRC_URL, DATES, PHONE_NAME, MODELS)"/>
<xsl:for-each select="/records/record[concat(SRC_URL, DATES, PHONE_NAME, MODELS) = $keyVal]">
<property name="{PROPERTY}" value="{VALUE1}"/>
</xsl:for-each>
</device>
</xsl:for-each>
</device-list>
</xsl:template>
</xsl:stylesheet>

Postnext
misha tsvetSubject: Same name and different property in xml
Author: misha tsvet
Date: 07 Jun 2006 01:56 PM
Thanks, it works good.

Postnext
misha tsvetSubject: Same name and different property in xml
Author: misha tsvet
Date: 07 Jun 2006 02:32 PM
maybe you know how to do this with Xquary?

Posttop
Minollo I.Subject: Same name and different property in xml
Author: Minollo I.
Date: 07 Jun 2006 03:08 PM
http://www.w3.org/TR/xquery/#id-grouping

 
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.