Jump to content

MikeC

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by MikeC

  1. I use the following which works fine in java script:<html><body> <script type="text/javascript"> //Comment - To create an instance of Microsoft's XML parser with JavaScript, use the following code: var xmlDoc=new ActiveXObject("Microsoft.XMLDOM") xmlDoc.async="false" //Comment - Then load the XML Document: xmlDoc.load("cd_catalogue.xml") //Comment - Same as above but then loading XSL Style Sheet: var xslDoc=new ActiveXObject("Microsoft.XMLDOM") xslDoc.async="false" xslDoc.load("cd_catalogue.xsl") //Comment - Transform xmlDoc with xslDoc and Write the output: document.write(xmlDoc.transformNode(xslDoc)) </script></body></html>I know it sound crazy, but you might want to change your transformnode function for transformNode, then I think it may work.Regards. Mike
  2. Hello Folks,I managed to solve my problem by use of the <xsl:call-template> element:............<!-- Comment: This template extracts information and present it as text description and number at the end of the list --><xsl:template match="/" name="footer"><xsl:text>The grand total of students on the module: </xsl:text><xsl:value-of select="$totalStudents"/><xsl:value-of select="$newline"/></xsl:template>..............Then executing the main template and including at the end:............. <!-- Comment: calling the template called 'footer' --> <xsl:call-template name="footer" /></xsl:template></xsl:stylesheet>Is anyone aware of a more active xslt forum?Good thoughts.Mike
  3. Sure - here is the .xsl file:<?xml version="1.0"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version = "1.0"><xsl:output method="text"/><!-- Comment: setting up a variable to create new line --><xsl:variable name="newline"><xsl:text></xsl:text></xsl:variable><!-- Comment: The registered variable uses the select expression to get all the RECORD element decendants in the XML document that have a child STAGECODE with value of Registered --><xsl:variable name="registered" select="//RECORD[sTAGECODE=Registered]"/><!-- Comment: The select expression uses the built-in XPATH count ( ) function that adds up the total number of nodes contained in the result tree fragmenmt stored in the registered variable --><xsl:variable name="totalRegStudents" select="count($registered)"/><xsl:variable name="tempRegisteredF" select="//RECORD[sTAGECODE=Temp Reg - Finance]"/><xsl:variable name="totalTempRegStudentsF" select="count($tempRegisteredF)"/><!-- Comment: First template to extract information and present in comma delimited format --><xsl:template match="/"> <xsl:for-each select="QLE/RECORD"> <!-- Comment: setting up the sort criteria for the output --> <xsl:sort select="SURNAME"/> <xsl:sort select="FAMILIARNAME"/> <!-- Comment: extracting student ID --> <xsl:value-of select="INSTITUTIONID"/> <xsl:text>,</xsl:text> <!-- Comment: removing the @roehampton.ac.uk from the E-mail Addr --> <xsl:value-of select="substring-before(INTERNALEMAIL, '@')" /> <xsl:text>,</xsl:text> <!-- Comment: removing the / from the Date of Birth --> <xsl:value-of select="translate(DATEOFBIRTH, '/', '')" /> <xsl:text>,</xsl:text> <xsl:value-of select="FAMILIARNAME"/> <xsl:text>,</xsl:text> <!-- Comment: replacing a space with hyphen in double-barreled surnames --> <xsl:value-of select="translate(SURNAME, ' ', '-')" /> <xsl:value-of select="$newline"/> </xsl:for-each> </xsl:template><!-- Comment: Second template to extract information and present as text description and number --><xsl:template match="/"><xsl:text>The total number of registered students: </xsl:text><xsl:value-of select="$totalRegStudents"/><xsl:value-of select="$newline"/><xsl:text>The total number of temporary registered students by Finance: </xsl:text><xsl:value-of select="$totalTempRegStudentsF"/><xsl:value-of select="$newline"/></xsl:template></xsl:stylesheet>....and here is fragment of the xml document:<QLE> <RECORD> <INTERNALEMAIL>bakkerh@roehampton.ac.uk</INTERNALEMAIL> <FAMILIARNAME>Hannah</FAMILIARNAME> <SURNAME>Baker</SURNAME> <INSTITUTIONID>03058947</INSTITUTIONID> <ACADEMICPERIOD>2005</ACADEMICPERIOD> <STUDENTID>ASA03058947</STUDENTID> <DATEOFBIRTH>13/03/78</DATEOFBIRTH> <STAGECODE>Registered</STAGECODE> <UCASID>032280159</UCASID> </RECORD> <RECORD> <INTERNALEMAIL>lockertp@roehampton.ac.uk</INTERNALEMAIL> <FAMILIARNAME>Pamela</FAMILIARNAME> <SURNAME>Lockert</SURNAME> <INSTITUTIONID>02018930</INSTITUTIONID> <ACADEMICPERIOD>2005</ACADEMICPERIOD> <STUDENTID>COO02018930</STUDENTID> <DATEOFBIRTH>23/06/82</DATEOFBIRTH> <STAGECODE>Temp Reg - Finance</STAGECODE> <UCASID>022496030</UCASID> </RECORD> </QLE>Appreciate your help.Good thoughts. Mike
  4. I have developed two separate xslt stylesheets using XMLSpy, which I can quite happily apply individually to an xml document. The <xsl:output method="text"/> in both cases. One style sheet provides a list and the second a count based upon the value of child element.Ideally I would like to combine these into a single stylesheet. So I have created a stylesheet that combines the two, where I have separated all the variables at the beginning and then created two templates bounded in each case by <xsl:template> & </xsl:template>. It seems that the second template gets actioned but not the first. When I comment out the second then the first works fine. I have been playing with <xsl:apply-templates /> element to see if this can help me invoke multiple templates on the same xml document, but without success. Can anybody point me in the right direction?I am not sure I totally have grasped the nature of the <xsl:apply-templates /> element although I have been through w3schools tutorial, but that does not give examples of the mode attribute. Can anybody to some online resources to simply explain the use of this element?Appreciate your help.Good thoughts. Mike
×
×
  • Create New...