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

RE: accessing xsl with XML DOM and javascript

Subject: RE: accessing xsl with XML DOM and javascript
From: "Chris Bayes" <Chris@xxxxxxxxxxx>
Date: Tue, 24 Jul 2001 14:54:19 +0100
javascript getattribute name
Elise,
>From the docs

getAttribute Method  [Script]
Gets the value of the attribute.

[Script]
Script Syntax
objValue = oXMLDOMElement.getAttribute(name);
Parameters
name
A string specifying the name of the attribute to return.
Return Value
A variant. Returns a string that contains the attribute value or returns the
empty string if the named attribute does not have a specified or default
value.

Example
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
var nodeBook, sIdValue;
xmlDoc.async = false;
xmlDoc.load("books.xml");
nodeBook = xmlDoc.selectSingleNode("//book");
sIdValue = nodeBook.getAttribute("id")
alert(sIdValue);
[Visual Basic]
Visual Basic Syntax
objValue = oXMLDOMElement.getAttribute(name)
Parameters
name
A string specifying the name of the attribute to return.
Return Value
A variant. Returns a string that contains the attribute value or returns the
empty string if the named attribute does not have a specified or default
value.
Remarks
You can also retrieve attributes by using the getNamedItem method of the
IXMLDOMNamedNodeMap.

So your code would be
return node.item(0).getAttribute("name");
or
return node.nextNode.getAttribute("name");

Ciao Chris

XML/XSL Portal
http://www.bayes.co.uk/xml


>-----Original Message-----
>From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Elise D.
>Sent: 24 July 2001 14:27
>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>Subject:  accessing xsl with XML DOM and javascript
>
>
>hi all,
>
>i do have an xsl where i call a javascript function
>inside :
>
>	<xsl:for-each select="./*[1]">
>		<tr bgcolor="6699cc">
>			<xsl:for-each select="./*">
>				<td>
>					><xsl:value-of
>select="user:getName(.)"/>
>				</td>
>			</xsl:for-each>
>		</tr>
>	</xsl:for-each>
>
>and here is the script inside the xsl :
>
><xsl:stylesheet
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>xmlns:msxsl="urn:schemas-microsoft-com:xslt"
>xmlns:user="urn:user-namespace-here" version="1.0">
><msxsl:script language="javascript"
>implements-prefix="user">
>	<![CDATA[
>    	function getName(node)
>	{
>		return node.item(0).nodeName;
> 	}
>	]]>
></msxsl:script>
>
>
>here is my xml structure :
>
><results>
>	<result>
>		<field name="Project Site">Paris</field>
>		<field name="end date">07/04/2001</field>
>		<field name="Project name">Microsoft Visio 10 VS
>Help </field>
>		<field name="Project Code">ITOSE01001</field>
>		<field name="Status">Go</field>
>	</result>
>        ....
></results>
>
>
>the problem is that my function returns me the name of
>the node (field) and in fact i'd like to get the value
>of the "name" attribute (example : end date).
>i tryed to put return
>node.attributes(0).getNamedItem("name");
>
>but it doesn't work.
>
>so someone give me the correct syntax ?
>
>regards,
>elise, xml learning girl
>
>___________________________________________________________
>Do You Yahoo!? -- Vos albums photos en ligne,
>Yahoo! Photos : http://fr.photos.yahoo.com
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>


 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.