Sign in to follow this  
kooktroop

(XSLT) Using node-set() with string output from a script

Recommended Posts

kooktroop    176
G'day, The aim of what I am doing is to sort through the XML, select the nodes I need and then output them. Currently, I am trying to iterate over the output from a script and display it using XSLT. Although the code below isn't doing anything complex at all, it's is to see how I would nodes from a script to the XSLT. I need the nodes returned from a script because I plan on doing a more complex selection process than XSLT offers. I have the following XSLT as a test script (the XML isn't required because I don't really use it, the main focus is on the msxml:script and the node-set() calls. I'm just trying to get this functionality working):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
	xmlns:msxsl="urn:schemas-microsoft-com:xslt"
	xmlns:msxml="urn:schemas-microsoft-com:xslt"
	xmlns:var="urn:var" 
	xmlns:user="urn:user" 
	exclude-result-prefixes="msxsl var user">
	
	<xsl:template match="//stage">
		<html>
			<head>
				<title>Title</title>
			</head>
			<body>
			

Workbook

<xsl:element name="p"> Test: <xsl:value-of select="user:test()" /> </xsl:element> <xsl:variable name="test_vardn"> <xsl:copy-of select="user:test()" /> </xsl:variable> Starting output: <xsl:element name="hr" /> <xsl:for-each select="msxsl:node-set($test_vardn)/deliverableinfo" >

<xsl:value-of select="@name" />

</xsl:for-each> <xsl:element name="hr" /> </body> </html> </xsl:template> <msxsl:script language="C#" implements-prefix="user"><![CDATA[ string test() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.AppendChild( xmlDoc.CreateElement( "root" ) ); XmlElement xmlElement = xmlDoc.CreateElement( "deliverableinfo" ); xmlElement.InnerText = "Figaro."; xmlDoc.DocumentElement.AppendChild( xmlElement ); return "<deliverableinfo name=\"tt\">Mwhuahauha</deliverableinfo><deliverableinfo name=\"_t_\">meow</deliverableinfo>"; //xmlDoc.DocumentElement.InnerXml; } string anothertest() { return "Mwhuahauhauuahua."; } ]]></msxsl:script> </xsl:stylesheet>
Thanks in advance!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this