Jump to content

ColtSanderus

Members
  • Posts

    9
  • Joined

  • Last visited

Profile Information

  • Location
    Belgium

ColtSanderus's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Hi!Thanks for your advice!Your 2nd solution looks great. I already did something similar to your recursive loop to perform a for, next loop.Because I have been using XSLT only for 2 weeks now, I also found other new stuff in your example.But I was running your implementation in my Visual Web Developper 2005 and it generates this error:'msxsl:node-set()' has failedIs a namespace reference sufficient to 'implement' an external funtion?------------ begin error description ------------ Server Error in '/ParseXMLWithXSLTToSVG' Application.--------------------------------------------------------------------------------Cannot convert the operand to 'Result tree fragment'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Xml.Xsl.XsltException: Cannot convert the operand to 'Result tree fragment'.Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [XsltException: Cannot convert the operand to 'Result tree fragment'.] System.Xml.Xsl.XsltOld.XsltFunctionImpl.ToNavigator(Object argument) +109 System.Xml.Xsl.XsltOld.FuncNodeSet.Invoke(XsltContext xsltContext, Object[] args, XPathNavigator docContext) +49 MS.Internal.Xml.XPath.FunctionQuery.Evaluate(XPathNodeIterator nodeIterator) +362[XPathException: Function 'msxsl:node-set()' has failed.] MS.Internal.Xml.XPath.FunctionQuery.Evaluate(XPathNodeIterator nodeIterator) +436 MS.Internal.Xml.XPath.BaseAxisQuery.Evaluate(XPathNodeIterator nodeIterator) +44------------ end error description ------------
  2. Hi,Indeed... this could be a solution but....It is not guarenteed that each line holds all three measurements "TCCxx". Therefore all column headers should be read from the top part of the xml source.So I still need a 'something' to store a node in it, to increment it in the outer for-each loop...I will try the node-set() function.
  3. Is this command line correct? (See context on page down) <xsl:value-of select="$activedatanode[@*[name()=$nodename]]"/>
  4. I didn't explain the problem very well....... so....First I wrote this xslt:<?xml version='1.0'?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema' xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'> <xsl:template match="/"> <h1>Data table</h1> <table border="1" bgcolor="#ADFF2F"> <!-- Write all header names to the table --> <tr> <xsl:for-each select="xml/s:Schema/s:ElementType/s:AttributeType"> <xsl:element name="td"> <xsl:attribute name="class">heading</xsl:attribute> <xsl:value-of select="@name"/> </xsl:element> </xsl:for-each> </tr> <!-- Write data into the table --> <xsl:for-each select="/xml/rs:data/rs:insert/z:row" > <xsl:variable name="activedatanode" select="."/> <tr> <xsl:for-each select="/xml/s:Schema/s:ElementType/s:AttributeType"> <td> <xsl:value-of select="@Date"/> </td> <td> <xsl:value-of select="@Time"/> </td> <td> <xsl:value-of select="@TCC18"/> </td> <td> <xsl:value-of select="@TCC19"/> </td> <td> <xsl:value-of select="@TCC20"/> </td> </tr> </xsl:for-each> </table> </xsl:template></xsl:stylesheet>This example outputs the content of attributes named "Date", "Time", "@TCC18", etc. The extension I want to implement now is that these attributes "Date", "Time", ... aren't fix, but they should be read from the xml file in the <s:Schema id='RowsetSchema'> section.So I would like to replace the section: <td> <xsl:value-of select="@Date"/> </td> <td> <xsl:value-of select="@Time"/> </td> <td> <xsl:value-of select="@TCC18"/> </td> <td> <xsl:value-of select="@TCC19"/> </td> <td> <xsl:value-of select="@TCC20"/> </td>by something like: <xsl:for-each select="/xml/s:Schema/s:ElementType/s:AttributeType"> <td> <xsl:variable name="nodename" select="@name"/> <xsl:value-of select="$activedatanode[@*[name()=$nodename]]"/> </td> </xsl:for-each>But this seems not to be correct.....This is the output I need:<table><tr><td class="heading">Date</td><td class="heading">Time</td><td class="heading">TCC18</td><td class="heading">TCC19</td><td class="heading">TCC20</td></tr><tr><td>13.05.2006</td><td>09:15:20</td><td>50</td><td>40</td><td>30</td></tr><tr><td>13.05.2006</td><td>09:15:22</td><td>60</td><td>40</td><td>10</td></tr><tr><td>13.05.2006</td><td>09:15:23</td><td>70</td><td>70</td><td>30</td></tr><tr><td>13.05.2006</td><td>09:15:24</td><td>80</td><td>40</td><td>30</td></tr><tr><td>13.05.2006</td><td>09:15:25</td><td>90</td><td>40</td><td>50</td></tr></table>
  5. Hi,I would like to parse data to a html table for each z:row the attributes defined by "AttributeType name" in the top of the same xml document.I tried something like:$activedatanode[@*[name()=$nodename]]"/to read out an attribute for all rows. The next loop should read out the second attribute for all rows. Does anybody have a better idea?XML:<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882' xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882' xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema'><s:Schema id='RowsetSchema'> <s:ElementType name='row' content='eltOnly' rs:updatable='true'> <s:AttributeType name='Date' rs:number='1' rs:write='true'> <s:datatype dt:type='string' dt:maxLength='255' rs:precision='0' rs:maybenull='false'/> </s:AttributeType> <s:AttributeType name='Time' rs:number='2' rs:write='true'> <s:datatype dt:type='string' dt:maxLength='255' rs:precision='0' rs:maybenull='false'/> </s:AttributeType> <s:AttributeType name='TCC18' rs:number='3' rs:write='true'> <s:datatype dt:type='string' dt:maxLength='255' rs:precision='0' rs:maybenull='false'/> </s:AttributeType> <s:AttributeType name='TCC19' rs:number='4' rs:write='true'> <s:datatype dt:type='string' dt:maxLength='255' rs:precision='0' rs:maybenull='false'/> </s:AttributeType> <s:AttributeType name='TCC20' rs:number='5' rs:write='true'> <s:datatype dt:type='string' dt:maxLength='255' rs:precision='0' rs:maybenull='false'/> </s:AttributeType> <s:extends type='rs:rowbase'/> </s:ElementType></s:Schema><rs:data> <rs:insert> <z:row Date='13.05.2006' Time='09:15:20' TCC18='50' TCC19='40' TCC20='30'/> <z:row Date='13.05.2006' Time='09:15:22' TCC18='60' TCC19='40' TCC20='10'/> <z:row Date='13.05.2006' Time='09:15:23' TCC18='70' TCC19='70' TCC20='30'/> <z:row Date='13.05.2006' Time='09:15:24' TCC18='80' TCC19='40' TCC20='30'/></xml>XSLT: <xsl:for-each select="/xml/rs:data/rs:insert/z:row" > <xsl:variable name="activedatanode" select="."/> <tr> <xsl:for-each select="/xml/s:Schema/s:ElementType/s:AttributeType"> <td> <xsl:variable name="nodename" select="@name"/> <xsl:value-of select="$activedatanode[@*[name()=$nodename]]"/> </td> </xsl:for-each> </tr> </xsl:for-each>
×
×
  • Create New...