Hello Guys,
I am new to this forum and to xml too
and I have a problem: I would like to loop according to two parameter 8key) the
roomName and price date but I do not know how to do that?
I got this result with my xsl file that with my xls transformation:
...
<TableRoom>
<ID>2</ID>
<Date>30.04.2005</Date>
<A> 115</A>
</TableRoom>
<TableRoom>
<ID>2</ID>
<Date>31.05.2005</Date>
<A> 115</A>
</TableRoom>
<TableRoom>
<ID>2</ID>
<Date>30.06.2005</Date>
<A> 115</A>
</TableRoom>
<TableRoom>
<ID>2</ID>
<Date>31.07.2005</Date>
<A> 100</A>
<B>462</B>
<A> 115</A> <PRÔBLEM HERE>
</TableRoom>
and what I would like it is to have something like this
For RoomName id = 2 and RoomName
Give me for this date the available price but I do not how to proceed
on that? someone Any Advice?
<TableRoom>...
<ID>2</ID>
<Date>30.06.2005</Date>
<A> 115</A>
</TableRoom>
<TableRoom>
<ID>2</ID>
<Date>31.07.2005</Date>
<A> 100</A>
<B>462</B>
</TableRoom>...
this is the xml file:
============
Code:
<?xml version="1.0"?>
<root>
<Rooms>
<Room>
<RommName>Suite</RommName>
<Informations>
<I>
<Currency>USD</Currency>
<Information>Internet</Information>
</I>
<price>
<A Date="31.07.2005"> 100</A>
<A Date="31.08.2005">411</A>
<A Date="30.09.2005">452</A>
<A Date="31.10.2005">452</A>
<B Date="31.07.2005">462</B>
<B Date="31.08.2005"> 125</B>
<B Date="30.09.2005">350</B>
</price>
</Informations>
</Room>
<Room>
<RommName>Little Suite</RommName>
<Informations>
<I>
<Currency>USD</Currency>
<Information>Internet</Information>
</I>
<price>
<A Date="30.04.2005"> 115</A>
<A Date="31.05.2005"> 115</A>
<A Date="30.06.2005"> 115</A>
<A Date="31.07.2005"> 115</A>
<A Date="31.08.2005">114</A>
<A Date="30.09.2005">115</A>
<B Date="31.08.2005">456</B>
<B Date="30.09.2005">456</B>
<B Date="31.10.2005"> 245</B>
<B Date="30.11.2005">250</B>
<B Date="31.12.2005">454</B>
</price>
</Informations>
</Room>
</Rooms>
</root>
This is the xsl
===========
Code:
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0"
xmlns:xsl=" <xsl
utput method="xml" indent="yes"/>
<xsl:variable name="roomName" select="root/Rooms/Room/RoomName"/>
<xsl:key name="dates" match="@Date" use="."/>
<!-- <xsl:key name="dates" match="@Date" use="concat($roomName)"/>-->
<xsl:template match="/">
<TEST>
<xsl:for-each select="root/Rooms/Room">
<TableID>
<xsl:apply-templates select="root/Rooms/Room"/>
<xsl:variable name="vRowInd">
<xsl:number count="Room" level="any"/>
</xsl:variable>
<ID>
<xsl:value-of select="$vRowInd"/>
</ID>
<roomName>
<xsl:value-of select="RommName"/>
</roomName>
</TableID>
</xsl:for-each>
<Price>
<xsl:apply-templates select=""/>
</Price>
</TEST>
</xsl:template><!--<xsl:template match="root/Rooms/Room">
<xsl:variable name="vRowInd">
<xsl:number count="Room" level="any"/>
<xsl
aram name="Id" select="$vRowInd"/>
</xsl:variable>
</xsl:template>-->
<xsl:template match="node()[not(descendant-or-self:
rice)] | @*">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="price">
<!-- problem here how to introduce the second parameter RoomName-->
<xsl:for-each select="*[count(key('dates',@Date)[1] | ./@Date) = 1
]">
<TableRoom>
<xsl:variable name="vRowInd">
<xsl:number count="Room" level="any"/>
</xsl:variable>
<ID>
<xsl:value-of select="$vRowInd"/>
</ID>
<Date>
<xsl:value-of select="@Date"/>
</Date>
<xsl:for-each select="key('dates', @Date)/parent::*">
<xsl:element name="{local-name()}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
</TableRoom>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
I am new to this forum and to xml too
and I have a problem: I would like to loop according to two parameter 8key) the
roomName and price date but I do not know how to do that?
I got this result with my xsl file that with my xls transformation:
...
<TableRoom>
<ID>2</ID>
<Date>30.04.2005</Date>
<A> 115</A>
</TableRoom>
<TableRoom>
<ID>2</ID>
<Date>31.05.2005</Date>
<A> 115</A>
</TableRoom>
<TableRoom>
<ID>2</ID>
<Date>30.06.2005</Date>
<A> 115</A>
</TableRoom>
<TableRoom>
<ID>2</ID>
<Date>31.07.2005</Date>
<A> 100</A>
<B>462</B>
<A> 115</A> <PRÔBLEM HERE>
</TableRoom>
and what I would like it is to have something like this
For RoomName id = 2 and RoomName
Give me for this date the available price but I do not how to proceed
on that? someone Any Advice?
<TableRoom>...
<ID>2</ID>
<Date>30.06.2005</Date>
<A> 115</A>
</TableRoom>
<TableRoom>
<ID>2</ID>
<Date>31.07.2005</Date>
<A> 100</A>
<B>462</B>
</TableRoom>...
this is the xml file:
============
Code:
<?xml version="1.0"?>
<root>
<Rooms>
<Room>
<RommName>Suite</RommName>
<Informations>
<I>
<Currency>USD</Currency>
<Information>Internet</Information>
</I>
<price>
<A Date="31.07.2005"> 100</A>
<A Date="31.08.2005">411</A>
<A Date="30.09.2005">452</A>
<A Date="31.10.2005">452</A>
<B Date="31.07.2005">462</B>
<B Date="31.08.2005"> 125</B>
<B Date="30.09.2005">350</B>
</price>
</Informations>
</Room>
<Room>
<RommName>Little Suite</RommName>
<Informations>
<I>
<Currency>USD</Currency>
<Information>Internet</Information>
</I>
<price>
<A Date="30.04.2005"> 115</A>
<A Date="31.05.2005"> 115</A>
<A Date="30.06.2005"> 115</A>
<A Date="31.07.2005"> 115</A>
<A Date="31.08.2005">114</A>
<A Date="30.09.2005">115</A>
<B Date="31.08.2005">456</B>
<B Date="30.09.2005">456</B>
<B Date="31.10.2005"> 245</B>
<B Date="30.11.2005">250</B>
<B Date="31.12.2005">454</B>
</price>
</Informations>
</Room>
</Rooms>
</root>
This is the xsl
===========
Code:
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0"
xmlns:xsl=" <xsl
<xsl:variable name="roomName" select="root/Rooms/Room/RoomName"/>
<xsl:key name="dates" match="@Date" use="."/>
<!-- <xsl:key name="dates" match="@Date" use="concat($roomName)"/>-->
<xsl:template match="/">
<TEST>
<xsl:for-each select="root/Rooms/Room">
<TableID>
<xsl:apply-templates select="root/Rooms/Room"/>
<xsl:variable name="vRowInd">
<xsl:number count="Room" level="any"/>
</xsl:variable>
<ID>
<xsl:value-of select="$vRowInd"/>
</ID>
<roomName>
<xsl:value-of select="RommName"/>
</roomName>
</TableID>
</xsl:for-each>
<Price>
<xsl:apply-templates select=""/>
</Price>
</TEST>
</xsl:template><!--<xsl:template match="root/Rooms/Room">
<xsl:variable name="vRowInd">
<xsl:number count="Room" level="any"/>
<xsl
</xsl:variable>
</xsl:template>-->
<xsl:template match="node()[not(descendant-or-self:
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="price">
<!-- problem here how to introduce the second parameter RoomName-->
<xsl:for-each select="*[count(key('dates',@Date)[1] | ./@Date) = 1
]">
<TableRoom>
<xsl:variable name="vRowInd">
<xsl:number count="Room" level="any"/>
</xsl:variable>
<ID>
<xsl:value-of select="$vRowInd"/>
</ID>
<Date>
<xsl:value-of select="@Date"/>
</Date>
<xsl:for-each select="key('dates', @Date)/parent::*">
<xsl:element name="{local-name()}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
</TableRoom>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>