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
the man with zestSubject: Presenting values in a table using two dimension positions in the XML.
Author: the man with zest
Date: 06 Jun 2007 08:58 AM

Hello,
i think i had to post my question here..so..
is there any elegant way to take two dimension positions from a XML file and generate a table with the values given using XSL?

the structure of the XML file goes like this:
/Level/DocLevel/Info/Sample/Request/Column
/Level/DocLevel/Info/Sample/Request/Row
/Level/DocLevel/Info/Sample/Request/Result

each Request holds the data and the positions - only the cells that contain some data.
the other cells of the table without the results need to be filled with NUll ( ).

if the table surrounded with the position indicators, for example the following:
<table border="1" width="80%">
<tr> <td>&#160;</td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td>
</tr>
<tr><td>A</td></tr>
<tr><td>B</td></tr>
<tr><td>C</td></tr>
<tr><td>D</td></tr>
<tr><td>E</td></tr>
<tr><td>F</td></tr>
<tr><td>G</td></tr>
<tr><td>H</td></tr>
</table>

how can i take the data from the XML and put it in the matching places?
Thanks in advance,
Zest

Postnext
Elias HuterSubject: Presenting values in a table using two dimension positions in the XML.
Author: Elias Huter
Date: 06 Jun 2007 10:03 AM
Originally Posted: 06 Jun 2007 09:28 AM
- Can you provide a sample XML, that would make things easier.
- Can you use XSLT 2.0 or are you bound to XSLT 1.0

I think that it will also be difficult because there are gaps (only non-empty fields provided) - a complete table would make things much easier. If there are gaps anyway, you also have to ask yourself whats the maximum value for Row and Column.

The solution that comes to my mind would be two nested recursive templates, but don't expect this to be an easy one.

Postnext
the man with zestSubject: Presenting values in a table using two dimension positions in the XML.
Author: the man with zest
Date: 06 Jun 2007 10:32 AM

Hi,
thanks for replying.
i thought about something related to Absolute Positioning.
i've started to check it - printing the basic table empty, than go throuth the XML and put the results when there's data in the XML.
i will define what are the the values for the cell (col and row) and multiply the indexs with the size defined.
this will (hopefully) place the data in place.
Kind Regards,
Zest
"Security, however, is an art, not a science." - RFC 3631.


Postnext
Elias HuterSubject: Presenting values in a table using two dimension positions in the XML.
Author: Elias Huter
Date: 06 Jun 2007 08:05 PM
Originally Posted: 06 Jun 2007 02:06 PM
So you define that there must not be more columns then lets say until "R" and not more rows than lets say "20" and draw an initial, empty table with that information first, right? That could work but keep in mind that I dont think you will be able to add values "afterwards". XSLT works sequently, so you have to add the values while builing up the empty table. Also this solution will not be bound to the max values and much typing-work with many coding lines. However it will probably also be the solution which costs you the fewest brain-work.

Postnext
the man with zestSubject: Presenting values in a table using two dimension positions in the XML.
Author: the man with zest
Date: 07 Jun 2007 03:13 AM

Helllooooooo
Well, It worked A-ok.
I agree. It's a solution (that worked) for a specific case and with the timetable I had it was a good one.
I need to do a more generic solution (two nested recursive templates?) – don't worry I'm not afraid of brain-work… &#61514;

Yes. I draw an empty table (like a board of a game with 1-12 and A-H for example) , and in the beginning I've declared few variables:

<xsl:variable name="StartFromLeftPoint" select="29" />
<xsl:variable name="StartFromUpPoint" select="157" />
<xsl:variable name="ShiftFromLeftToRight" select="45" />
<xsl:variable name="ShiftFromUpToDown" select="45" />

Later in the code:

<table>
<tr>
<td>
<!-- printing the basic table -->
<xsl:call-template name="PrintTable"></xsl:call-template>
</td>
</tr>
<tr>
<td>
<!-- printing the data inside the table -->
<xsl:for-each select="TrayInfo/Sample/Request">
<xsl:variable name="CurrentTop" select="$StartFromUpPoint + (Row * $ShiftFromUpToDown) + Row "/>
<xsl:variable name="CurrentLeft" select="$StartFromLeftPoint + (Column * $ShiftFromLeftToRight) + Column "/>
<td align="center" bgcolor="green">
<xsl:attribute name="style">
<xsl:value-of select="concat('position: absolute; top:',concat($CurrentTop,'px;') ,' left: ' ,concat($CurrentLeft,'px;'))"/>
</xsl:attribute>
<xsl:value-of select="Result"/>
</td>
</xsl:for-each>
</td>
</tr>
</table>

The addition in the end of the variables CurrentTop and CurrentLeft are related to the shift of the borders that infect.

Kind Regards,
Elad Shapira ("Zest")
"Security, however, is an art, not a science." - RFC 3631.

Posttop
Tony LavinioSubject: Presenting values in a table using two dimension positions in the XML.
Author: Tony Lavinio
Date: 07 Jun 2007 09:09 AM
For XSLT-specific questions, there are two good reference places.
The XSLT Cookbook, ISBN 0-596-00974-7

And the XSL-LIST mailing list, run by Mulberry Technologies.

Although we're happy to provide free support to our users, neither
your name nor your email address appear to belong to a registered user.

 
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.