[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Hopefully not a terribly silly question

Subject: Hopefully not a terribly silly question
From: Morgan Goeller <morganworks@xxxxxxx>
Date: Thu, 03 Jan 2002 10:21:36 -0700
who is morgan goeller
Hello all!


This is my first posting to the list, and I hope it is not a terribly silly question. I normally try like the dickens not to have to ask for help on mailing lists, but after searching the archives and the web I can't seem to come up with an answer. Please bear with me. I am using a product called ODBC Socket Server, which allows UNIX machines to get ODBC information from Windows boxes. The information is returned as XML data which looks something like this:


<result state="success">
<row>
<column name="aspect_task_id">70006</column>
<column name="aspect_task_descr">Tucson - Update CCIS_SISO_SUMMARY</column>
<column name="dep_task_descr">End of Switch Procedures - tuc</column>
<column name="dep_task_id">70290</column>
<column name="dep_task_grp">Aspect Data Loads</column>
</row>
<row>
<column>70007</column>
<column>Tucson HQ - Update CCIS_SISO_SUMMARY</column>
<column>End of Switch Procedures - tuchq</column>
<column>70390</column>
<column>Aspect Data Loads</column>
</row>
.
. .


</result>


I need to translate this into something like:


<row aspect_task_id="...." aspect_task_descr="......" dep_task_descr="....." dep_task_id="....." dep_task_grp="....." />
<row aspect_task_id="...." aspect_task_descr="......" dep_task_descr="....." dep_task_id="....." dep_task_grp="....." />
<row aspect_task_id="...." aspect_task_descr="......" dep_task_descr="....." dep_task_id="....." dep_task_grp="....." />
<row aspect_task_id="...." aspect_task_descr="......" dep_task_descr="....." dep_task_id="....." dep_task_grp="....." />
<row aspect_task_id="...." aspect_task_descr="......" dep_task_descr="....." dep_task_id="....." dep_task_grp="....." />



I am trying to iterate through each of the rows, then each of the columns. If I am not in the first column then I want to get a hold of the name attribute from the first row and apply it. I wrote a stylesheet that tries to grab just those attributes that looks like:


<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes"/>


<xsl:template match="/"> <xsl:for-each select="/result/row">
<xsl:for-each select="./column">
<xsl:call-template name="print_name"/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>


<xsl:template name="print_name">
<xsl:choose>
<xsl:when test="@name"> Name = <xsl:value-of select="@name"/> </xsl:when>
<xsl:otherwise> Name <xsl:value-of select="position()"/>=
<xsl:value-of select="concat('/result/row[1]/column[', position(),']/@name')"/> Value <xsl:value-of select="position()"/>=<xsl:value-of select="."/> </xsl:otherwise>
</xsl:choose>
</xsl:template>


</xsl:stylesheet>

Unfortunately, I get a the literal string result of the concat() function, instead of the actual data value. Is there some sort of eval() function that I need to use? Am I approaching this incorrectly? I know that XSL is quite a paradigm shift from traditional programming methods.

Morgan Goeller

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"For every complex problem, there is a solution that is simple, neat, and wrong."
-- H.L. Mencken (1880-1956)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.