Jump to content

aalbetski

Members
  • Posts

    331
  • Joined

  • Last visited

Everything posted by aalbetski

  1. As far as I know, XPATH (the language of XSLT) does not provide a mechanism for dealing with anything other than the XML tree contained in the file (or memory stream, or data island, or whatever the container may be).You may be able to use a Javascript or VBScript extension and create an instance of the FileScriptingObject, but even then, it won't be able to derive the name.To accomplish what you want, you'll need to pass the filename in as a parameter.
  2. second frame has no border, no scrollbars. Tested in IE only<frameset rows="50%,*" > <frame frameborder="1" scrolling="yes" src="HomePage.htm"></frame> <frame frameborder="0" scrolling="no" src="HomePage.htm"></frame></frameset>
  3. here is a complete example (will only work in IE, but from what I can tell, thats what you're using). Because this is using client-side script you will have difficulity in publishing it with all the blocks there are now for objects and such, you may want to consider ASP for that reason, but nonetheless, this is a complete, working example:The CSV file I used (called tdcLinks.csv) "Office","URL""Anoka MN","http://www.mapquest.com/directions/main.ad...z=55303&r=f""Arlington MN","http://www.mapquest.com/directions/main.ad...z=55307&r=f""Ashland WI","http://www.mapquest.com/directions/main.ad...z=54806&r=f" The HTML <html><script for="placeholder" event="onclick"> window.open(window.event.srcElement.value);</script><body onLoad="LoadCSV()"> <OBJECT classid="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83" ID=tdcLinks HEIGHT=0 WIDTH=0> <PARAM NAME="DataURL" VALUE="tdcLinks.csv"> <PARAM NAME="UseHeader" VALUE="True"> </OBJECT> <select id="placeholder"/></body><script>function LoadCSV(){ var html = "" html += "<select id='placeholder'>" tdcLinks.recordset.MoveFirst() while(!tdcLinks.recordset.eof) { html += '<option value="' + tdcLinks.recordset.fields('URL').value + '">' + tdcLinks.recordset.fields('Office').value + '</option>' tdcLinks.recordset.MoveNext() } html += "</select>" document.getElementById("placeholder").outerHTML = html}</script></html>
  4. you're close. try something along these lines: var html = ""html += "<select id='placeholder'>"if(!tdcLinks.recordset.bof) { tdcLinks.recordset.MoveFirst() while(!tdcLinks.recordset.eof) { html += '<option value="' + dcLinks.recordset.fields(id).value + '">' + dcLinks.recordset.fields(val).value + '</option>' tdcLinks.recordset.MoveNext() } } tdcLinks.recordset.close()html += "</select>" It probably needs to be cleaned up. just send the html string to the outerHTML of an existing <select>ex:<select id="placeholder" />document.getElementById('placeholder').outerHTML = html
  5. Thats where I was going, but first I want to understand what your expected result is before I propose a solution.Now, show the code that you use to read the CSV file
  6. XSLT has two methods to use external XSLT files xsl:imports and xsl:include
  7. So, is this you're desired result?<select><option value="ttp://www.mapquest.com/directions/main.ad...z=55303&r=f">Anoka MN</option><option value="ttp://www.mapquest.com/directions/main.ad...z=55307&r=f">Arlington MN</option><option value="ttp://www.mapquest.com/directions/main.ad...z=54806&r=f">Ashland WI</option></select>
  8. from http://developer.mozilla.org/en/docs/DOM:element.innerHTML from http://www.webreference.com/js/tips/001209.html It cannot be guaranteed that every browser will support this property. It was (at least originally) limited to IE only
  9. I believe this is a Microsoft extension to the HTML DOM and is not a standard across all browers.http://msdn.microsoft.com/library/default....s/innerHTML.asp
  10. Another approach would be just to type this into the address bar and see what errors you get:http://www.w3schools.com/xml/note.xmlWhen I do this using IE 6.0, I see the contents of the file. If get an error and are refused access, then you need to find out why your browser is not able to access the file.
  11. then you have a security issue or a firewall blocking. It renders fine for me
  12. my 2c hereIE 7.0 does not render the background-attachment attribute properly. It causes the image not to display at all, try removing any references to that attribute.There may be other quirks as well, try experimenting with the attributes
  13. Its probably working fine. You just need to do something with the response. Try this: var xmlSource=new ActiveXObject("Microsoft.XMLDOM")xmlSource.async=falsexmlSource.load("http://www.w3schools.com/xml/note.xml")document.write("<textarea style='height:90%;width:100%'>" + xmlSource.xml + "</textarea>");
  14. you can probably do this with an instance of the Excel.Application. It would mean that you need Excel installed on your server as well as the appropriate permissions set for IIS to access Excel. You will then need to study up on the methods and objects that Excel exposes through automation.To get you started:<%@ language="vbscript" %><%Dim oExcelDim oWorkbookDim oWorksheetSet oExcel = Server.CreateObject("Excel.Application")Set oWorkbook = oExcel.Workbooks.Open("workbook.xls")Set oWorksheet = oWorkbook.Sheets("Sheet1")Response.Write(oWorksheet.Name)%>
  15. This one was a toughie. I received (much appreciated) assistance from Michael Kay who steered me in the right direction. The pitfall was the grouping on the sub tree. I quote Mr. Kay Taking his advice and with one minor change in his code, I (we) came up with thisThe XML used<PublisherList> <publisher> <name>Penguin</name> <books> <book> <title>Title One</title> <author>David</author> </book> <book> <title>Title Two</title> <author>John</author> </book> <book> <title>Title Three</title> <author>John</author> </book> <book> <title>Title Four</title> <author>David</author> </book> </books> </publisher> <publisher> <name>Wrox</name> <books> <book> <title>Title Five</title> <author>David</author> </book> <book> <title>Title Six</title> <author>John</author> </book> <book> <title>Title Seven</title> <author>John</author> </book> <book> <title>Title Eight</title> <author>David</author> </book> </books> </publisher></PublisherList> The XSLT used <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml"/> <xsl:key name="authors" match="author" use="concat(ancestor::publisher/name, '#', .)" /> <xsl:template match="/"> <xsl:element name="List"> <xsl:for-each select="//publisher"> <xsl:variable name="publisher" select="name"/> <xsl:element name="BookPublisher"> <xsl:element name="name"> <xsl:value-of select="$publisher"/> </xsl:element> <xsl:for-each select=".//author[count(.| key('authors', concat($publisher, '#', .))[1])=1]"> <xsl:element name="BooksByAuthor"> <xsl:variable name="AuthorName" select="." /> <xsl:element name="AuthorName"> <xsl:value-of select="$AuthorName"/> </xsl:element> <xsl:for-each select="//book[ancestor::publisher/name=$publisher][author=$AuthorName]/title"> <xsl:element name="title"> <xsl:value-of select="."/> </xsl:element> </xsl:for-each> </xsl:element> </xsl:for-each> </xsl:element> </xsl:for-each> </xsl:element> </xsl:template></xsl:stylesheet> the result <?xml version="1.0"?><List> <BookPublisher> <name>Penguin</name> <BooksByAuthor> <AuthorName>David</AuthorName> <title>Title One</title> <title>Title Four</title> </BooksByAuthor> <BooksByAuthor> <AuthorName>John</AuthorName> <title>Title Two</title> <title>Title Three</title> </BooksByAuthor> </BookPublisher> <BookPublisher> <name>Wrox</name> <BooksByAuthor> <AuthorName>David</AuthorName> <title>Title Five</title> <title>Title Eight</title> </BooksByAuthor> <BooksByAuthor> <AuthorName>John</AuthorName> <title>Title Six</title> <title>Title Seven</title> </BooksByAuthor> </BookPublisher></List> Looks pretty good to me, Thanks Mike!
  16. the load function will return true if the load was successful, false if not
  17. Here is the code for a VB.NET (2.0) app transforming XML using XSLT and a XmlWebControl. It's actually simpler than before. This is not the same XML that was used in this thread, but the syntax is the same Dim xa As New XsltArgumentList xa.AddParam("color", "", "red") Me.Xml1.TransformArgumentList = xa Me.Xml1.DocumentSource = (MapPath("items1.xml")) Me.Xml1.TransformSource = (MapPath("items1.xsl"))
  18. I reproduced your error using ASP.NET 2.0 and discovered that the msxsl:node-set extension is no longer needed (or supported) by VS 2005. This revised code works fine. I have tested it and it renders the table just fine using VS 2005. If you are going to invoke the MSXML parser using new ActiveXObject (or CreateObject in vbscript) then you will still need the node-set extension. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema' xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882' version="1.0"> <xsl:output method="html"/> <xsl:variable name="Attributes" select="//s:AttributeType" /> <xsl:template match="/"> <table border="1"> <tr><xsl:apply-templates select="$Attributes/@*[name()='name']" /></tr> <xsl:call-template name="DoARow2" /> </table> </xsl:template> <xsl:template match="@*"> <td><xsl:value-of select="." /></td> </xsl:template> <xsl:template name="DoARow2"> <xsl:param name="RowNumber" select="1"/> <xsl:param name="TotalRows" select="count(//z:row)" /> <tr><xsl:apply-templates select="//z:row[$RowNumber]"/></tr> <xsl:if test="$RowNumber < $TotalRows"> <xsl:call-template name="DoARow2" > <xsl:with-param name="RowNumber" select="$RowNumber + 1"/> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template match="z:row"> <xsl:variable name="zrow" select="."/> <xsl:for-each select="$Attributes/@*[name()='name']"> <xsl:variable name="attrib" select="."/> <td> <xsl:value-of select="$zrow/@*[name() = $attrib]" /> </td> </xsl:for-each> </xsl:template></xsl:stylesheet> p.s. Just to clarify, I did run this in VS 2005 (albeit using deprecated methods, but thats a different problem) and it works OKHeres the ASP.NET code-behind protected void Page_Load(object sender, EventArgs e) { XslTransform xsl = new XslTransform(); xsl.Load(MapPath(@"items1.xsl")); XmlDocument xml = new XmlDocument(); xml.Load(MapPath(@"items1.xml")); this.Xml1.Document = xml; this.Xml1.Transform = xsl; } and yes, I know that these objects and methods are deprecated , but that wasn't the issue at hand
  19. Its a reference to a node-set, but it is not necessary to use the node-set() extension (even though your 'correction' works, my original text was not incorrect). I suggest that you copy the XSLT and XML (from my first post) and transform them. They work (at least they do using XMLDOM and Javascript, jury still out on VS 2005)
  20. just a clarification, the line that robot 'corrected' is not an error. the original line is correct<xsl:value-of select="$zrow/@*[name() = $attrib]" /> The $zrow variable referenced is the current node in the context of the template. <xsl:template match="z:row">--->>>>> <xsl:variable name="zrow" select="."/> <xsl:for-each select="msxsl:node-set($Attributes)/@*[name()='name']"> <xsl:variable name="attrib" select="."/> <td> <xsl:value-of select="$zrow/@*[name() = $attrib]" /> </td> </xsl:for-each> </xsl:template> Additionally, your code will not work <xsl:variable name="currentPosition" select="@*/position()"/> The position() function is intended to return the value of the context position, it cannot be used to determine the position of an attribute as you attempted to do.
  21. trt this:<input type="radio" name="sourceClass" value="Point Source" onClick="toggleVisible(this);" /> Point Source<br />function toggleVisible(object) { object.style.display = 'none';}
  22. aalbetski

    xpath problem

    using XSLT , I came up with this <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html"/> <xsl:template match="//menu[@id='buddies']"> <xsl:for-each select="ancestor-or-self::*[name()='menu']"> <xsl:value-of select="name()"/><br/> </xsl:for-each> </xsl:template> </xsl:stylesheet> using XMLDOM (msxml parser) and Javascript var oNode = xmlSource.selectSingleNode("//menu[@id='buddies']")var oNodes = oNode.selectNodes("ancestor-or-self::*[name()='menu']")
  23. I have limited experience with VS 2005. This was done with Javascript creating an instance of the MSXSL 4.0 parser.Let me have a go with my VS 2005. In the meantime, if you find out something, post itWere using C# or VB.NET? WebForm or WinForm?
  24. I was intrigued by this and did it two ways. The first way simply takes the attributes (names and data) from the z:row and builds the table. The second follows your original request to obtain the names from the s:attribute nodes and then build the table. Either way worksThe trick for each is breaking on the row for each time the z:row changes. For that I used a variation of the recursive table builder that I posted a while back. Try these and see if they fit your needs:This XML (non-essential data was removed) <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: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'/></rs:insert></xml> The first XSLT (my 1st choice, its simpler): <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema' xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882' version="1.0"> <xsl:output method="html"/> <xsl:template match="/"> <table border="1"> <tr><xsl:apply-templates select="//z:row[1]/@*" mode="heading"/></tr> <xsl:call-template name="DoARow" /> </table> </xsl:template> <xsl:template name="DoARow"> <xsl:param name="RowNumber" select="1"/> <xsl:param name="TotalRows" select="count(//z:row)" /> <tr><xsl:apply-templates select="//z:row[$RowNumber]/@*" mode="data"/></tr> <xsl:if test="$RowNumber < $TotalRows"> <xsl:call-template name="DoARow" > <xsl:with-param name="RowNumber" select="$RowNumber + 1"/> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template match="@*" mode="heading"> <td><xsl:value-of select="name()"/></td> </xsl:template> <xsl:template match="@*" mode="data"> <td><xsl:value-of select="." /></td> </xsl:template></xsl:stylesheet> The second XSLT, which matches your original question of using the s:attribute nodes to obtain the names. It uses the node-set() <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema' xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882' xmlns:msxsl="urn:schemas-microsoft-com:xslt" version="1.0"> <xsl:output method="html"/> <xsl:variable name="Attributes" select="//s:AttributeType" /> <xsl:template match="/"> <table border="1"> <tr><xsl:apply-templates select="msxsl:node-set($Attributes)/@*[name()='name']" /></tr> <xsl:call-template name="DoARow2" /> </table> </xsl:template> <xsl:template match="@*"> <td><xsl:value-of select="." /></td> </xsl:template> <xsl:template name="DoARow2"> <xsl:param name="RowNumber" select="1"/> <xsl:param name="TotalRows" select="count(//z:row)" /> <tr><xsl:apply-templates select="//z:row[$RowNumber]"/></tr> <xsl:if test="$RowNumber < $TotalRows"> <xsl:call-template name="DoARow2" > <xsl:with-param name="RowNumber" select="$RowNumber + 1"/> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template match="z:row"> <xsl:variable name="zrow" select="."/> <xsl:for-each select="msxsl:node-set($Attributes)/@*[name()='name']"> <xsl:variable name="attrib" select="."/> <td> <xsl:value-of select="$zrow/@*[name() = $attrib]" /> </td> </xsl:for-each> </xsl:template></xsl:stylesheet> This result (for both solutions): Date Time TCC18 TCC19 TCC20 13.05.2006 09:15:20 50 40 30 13.05.2006 09:15:22 60 40 10 13.05.2006 09:15:23 70 70 30 13.05.2006 09:15:24 80 40 30
×
×
  • Create New...