Hi, Please help me in doing an xsl transformation on an xml so as to
get the desired output. Following is the input to which xsl transformation is
to be done and the desired output after transformation: Input <xforms:select1 appearance="full"
ref="cardtype">
<xforms:label></xforms:label>
<xforms:item>
<xforms:label></xforms:label>
<xforms:value>visa</xforms:value>
</xforms:item>
<xforms:item>
<xforms:label></xforms:label>
<xforms:value>master</xforms:value>
<xforms:extension>
<itemlocation>
<x>160</x>
<y>4</y>
</itemlocation>
</xforms:extension>
</xforms:item>
<xforms:item>
<xforms:label></xforms:label>
<xforms:value>american</xforms:value>
<xforms:extension>
<itemlocation>
<x>331</x>
<y>4</y>
</itemlocation>
</xforms:extension>
</xforms:item>
</xforms:select1> Output
<xforms:select1 style="position:absolute;top:;left:;"
appearance="full" ref="cardtype">
<xforms:label/>
<xforms:item>
<xforms:label/>
<xforms:value>visa</xforms:value>
</xforms:item>
</xforms:select1>
<xforms:select1 style="position:absolute;top:4;left:160;"
appearance="full" ref="cardtype">
<xforms:item>
<xforms:label/>
<xforms:value>master</xforms:value>
</xforms:item>
</xforms:select1> <xforms:select1
style="position:absolute;top:4;left:331;" appearance="full"
ref="cardtype">
<xforms:item>
<xforms:label/>
<xforms:value>american</xforms:value>
</xforms:item>
</xforms:select1> That is, we are splitting each ‘item’ in a ‘select’
control to separate ‘select’ controls so that its position can be
controlled. Thanks in advance Jency -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Hi Jency,
> Please help me in doing an xsl transformation on an xml so as to get the > desired output. Following is the input to which xsl transformation is to > be done and the desired output after transformation: > (...) > That is, we are splitting each ‘item’ in a ‘select’ control to separate > ‘select’ controls so that its position can be controlled. you could achieve that result with the following xslt transformation: <xsl:stylesheet version="2.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <result xmlns="" xmlns:xforms="http://www.w3.org/2002/xforms"> <xsl:apply-templates /> </result> </xsl:template> <xsl:template match="xforms:select1"> <xsl:for-each select="xforms:item"> <xsl:variable name="top" select="xforms:extension/itemlocation/x" /> <xsl:variable name="left" select="xforms:extension/itemlocation/y" /> <xsl:element name="xforms:select1"> <xsl:attribute name="style" select="concat('position:absolute;top:', $top, ';left:', $left, ';')" /> <xsl:copy-of select="parent::xforms:select1/@*"/> <xsl:copy> <xsl:apply-templates /> </xsl:copy> </xsl:element> </xsl:for-each> </xsl:template> <xsl:template match="xforms:extension" /> <xsl:template match="*|@*|text()"> <xsl:copy> <xsl:apply-templates /> </xsl:copy> </xsl:template> </xsl:stylesheet> I've added an additional root element named "result" as a container for the select1 elements. I'm sure there are more elegant solutions, because i'm not an xslt specialist... HTH florian -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Thanks Florian. It helped.
-----Original Message----- From: Florian Schmitt [mailto:[hidden email]] On Behalf Of Florian Schmitt Sent: Thursday, June 14, 2007 1:02 AM To: [hidden email] Subject: Re: [ops-users] xsl transformation Hi Jency, > Please help me in doing an xsl transformation on an xml so as to get > the desired output. Following is the input to which xsl transformation > is to be done and the desired output after transformation: > (...) > That is, we are splitting each ‘item’ in a ‘select’ control to > separate ‘select’ controls so that its position can be controlled. you could achieve that result with the following xslt transformation: <xsl:stylesheet version="2.0" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <result xmlns="" xmlns:xforms="http://www.w3.org/2002/xforms"> <xsl:apply-templates /> </result> </xsl:template> <xsl:template match="xforms:select1"> <xsl:for-each select="xforms:item"> <xsl:variable name="top" select="xforms:extension/itemlocation/x" /> <xsl:variable name="left" select="xforms:extension/itemlocation/y" /> <xsl:element name="xforms:select1"> <xsl:attribute name="style" select="concat('position:absolute;top:', $top, ';left:', $left, ';')" /> <xsl:copy-of select="parent::xforms:select1/@*"/> <xsl:copy> <xsl:apply-templates /> </xsl:copy> </xsl:element> </xsl:for-each> </xsl:template> <xsl:template match="xforms:extension" /> <xsl:template match="*|@*|text()"> <xsl:copy> <xsl:apply-templates /> </xsl:copy> </xsl:template> </xsl:stylesheet> I've added an additional root element named "result" as a container for the select1 elements. I'm sure there are more elegant solutions, because i'm not an xslt specialist... HTH florian -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Free forum by Nabble | Edit this page |