Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

transformation on client with data islands

Status
Not open for further replies.

tyris

Programmer
Nov 2, 2000
311
FR
hi all,
i've found a tutorial here : that could help me to create my own XSLT. the problem is that all the code used for the transformation is in VBscript. what i wanted to know is : is there a way to create MSXML3 objects, transform data island xml... in javascript ? i don't want to use vbscript.

is there a way to do this kind of stuff in javascript ? :

===========================================

this code is used to sort a table :
Code:
function sort(strField)
		'change the sort order and redisplay
		dim sortField
		dim sortOrderAttribute
		'Attach to select attribute of the sort element attribute
		set sortField=Style.XMLDocument.selectSingleNode("//xsl:sort/@strField")
		'Attach to the sort attribute
		set sortOrderAttribute = _
			Style.XMLDocument.selectSingleNode("//xsl:sort/@order")
			
		'If you are already sorting by strField
		if sortField.value = strField then
			'change the order
			if sortOrderAttribute.value = "descending" _
				then
				sortOrderAttribute.value = "ascending" 
			else
				sortOrderAttribute.value = "descending" 
			end if
		else 
			'sort ascending
			sortField.value = strField 
			sortOrderAttribute.value = "ascending" 
		end if 
		
		set sortField = nothing
		set sortOrderAttribute = nothing
		
		DisplayArea.innerHTML = Data.transformNode _
			(Style.DocumentElement)
	end function
==============================================

this code is used in an hmtl file structured this way (and mine will be a bit the same):
Code:
<HTML>
<Head>

<Script language=&quot;vbscript&quot;>
option explicit
function window_onload()

   transform()

end function

function transform()

   DisplayArea.innerHTML = Data.transformNode _
      (Style.DocumentElement)

end function

</Script>
</Head>
<body>

<XML id='Data'>
   <Addresses>
      <Address>
         <id></id>
         <FirstName></FirstName>
         <LastName></LastName>
         <State></State>
      </Address>
   </Addresses>
</XML>
<XML id='Style' src='Log.xsl'></XML>

<span id=&quot;DisplayArea&quot;></span>

</body>
</HTML>
================================================

Best regards,
Elise, XML learning girl X-)
 
Hello, Elise,
The code is almost the same:
<html>
<head>

<script language=&quot;JavaScript&quot;>
function transform() {
//The followng code is on one line
DisplayArea.innerHTML = Data.transformNode(Style.documentElement)
}
</script>

</head>
<body onLoad=&quot;transform()&quot;>

<XML id='Data'>
<Addresses>
<Address>
<id>5</id>
<FirstName>John</FirstName>
<LastName>Smith</LastName>
<State>CA</State>
</Address>
</Addresses>
</XML>
<XML id='Style' src='Log.xsl'></XML>

<span id=&quot;DisplayArea&quot;></span>

</body>
</html>

I suppose you have Log.xsl file in the same directory as this .html file.


The function sort have to be transformed in similar way in JavaScript function.
The xml methods and attributes are the same for both languages.
Only some syntaxis is different for defining functions, variables, loops.
See
for JavaScript/VBScript/XML/XSL

Take care to not to use naming spce xmlns:xsl=&quot; - it is outdated and you will have troubles with more sofisticated xsl.

Success!
D.
 
yes i already know this, i do use MS XSL 3. thanks for your clear answer. you explain very well. Best regards,
Elise, XML learning girl X-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top