Jump to content

Search the Community

Showing results for tags 'for-each'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Found 3 results

  1. Hi I have a problem with counting the number of data rows for an XML nodes. A sample XML is listed below. <Contract> <Lease>12345</Lease> <trdate>12-sep-1990</trdate> <customer id="1"> <name>tanket</name> <country>timbaktu</country> <creditrating>500</creditrating> </customer> <Locations> <Location cillicode="13456"> <title>SharptonWorks</title> <GPSCoordinate>17:45,36</GPSCoordinate> </Location> <Location cillicode="873456"> <title>MickeyTowers</title> <GPSCoordinate>67:45,36</GPSCoordinate> </Location> </Locations> <Phonegrp> <HQ> <vicepresident>1234567890</vicepresident> <security>76543421</security> <reception>123458899</reception> </HQ> <shipping> <oilsandpaints>9876543210</oilsandpaints> <steel>887772929</steel> </shipping> </Phonegrp> </Contract> --this would have to be transformed to --within each data rows the elements become attributes for the data row. --the number of data rows for a group is then counted. <Contract Lease="12345" trdate="12-sep-1990"> <customer id="1" name="tanket" country="timbaktu" creditrating="500"></customer> <Locations Count="2"> <Location cillicode="13456" title="SharptonWorks" GPSCoordinate="17:45,36"></Location> <Location cillicode="873456" title="MickeyTowers" GPSCoordinate="67:45,36"></Location> </Locations> <Phonegrp Count="2"> <HQ vicepresident="1234567890" security="76543421" reception="123458899"></HQ> <shipping oilsandpaints="9876543210" steel="887772929"></shipping> </Phonegrp> </Contract> The generic XSLT below translates the elements into named attributes but am running into issues trying to set the row count for the immediate parent node as described above The node that would qualify to receive the count would be the one which nearest parent which has no Named attributes on it. Is this something which can be easily addressed. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="*"> <xsl:copy> <xsl:for-each select="@*|*[not(* or @*)]"> <xsl:attribute name="{name(.)}"><xsl:value-of select="."/> </xsl:attribute> </xsl:for-each> <xsl:apply-templates select="*[* or @*]|text()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
  2. Hello, My stylesheet failed to compile for this error: XPTY0020: Cannot select a node here: the context item is an atomic value at this line: <xsl:when test="$event[substring-before(start/datetime, 'T')=$dateJour]"> Here is all the code of the template: http://pastebin.com/fmPUHGpR. The error is on line 20. Yesterday, I search on a lot of websites and forums who says to put a global variable outside the for-each. $event is a global variable. I try to put event/start/datetime in a global variable but I still have the error. Could you please help me?
  3. We receive an XML document that has several repeating elements. These are optional and can have from 0 to n number. We can only handle 2. How do we just get the first 2 of a set? The for-each gets all which messes up the output that we need. Below is an example of the incoming XML <opts length="4"><opt>Val1</opt><opt>Val2</opt><opt>Val3</opt><opt>Val4</opt></opts>
  • Create New...