Click here to Skip to main content
15,914,943 members
Home / Discussions / XML / XSL
   

XML / XSL

 
GeneralRe: selectSingleNode from a relative position Pin
Ranjan Banerji14-Jul-03 7:30
Ranjan Banerji14-Jul-03 7:30 
GeneralRe: selectSingleNode from a relative position Pin
mcdirge14-Jul-03 7:57
mcdirge14-Jul-03 7:57 
General2 xml file to 1 datagrid Pin
jphuphilly11-Jul-03 6:51
jphuphilly11-Jul-03 6:51 
GeneralRe: 2 xml file to 1 datagrid Pin
Not Active11-Jul-03 8:27
mentorNot Active11-Jul-03 8:27 
Generalbind xml datagrid Pin
jphuphilly9-Jul-03 10:47
jphuphilly9-Jul-03 10:47 
GeneralRe: bind xml datagrid Pin
jphuphilly11-Jul-03 7:53
jphuphilly11-Jul-03 7:53 
General.NET DataSet -> Xml + XSLT -> HTML Pin
dratti9-Jul-03 5:28
dratti9-Jul-03 5:28 
GeneralRe: .NET DataSet -> Xml + XSLT -> HTML Pin
Philip Fitzsimons9-Jul-03 6:56
Philip Fitzsimons9-Jul-03 6:56 
use need to use the name() function in xslt.
In order to not hard code element names you should pass them as parameters to your xslt.

so something like:
<?xml version="1.0" encoding="UTF-8" ?><br />
<xsl:stylesheet <br />
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"<br />
  version="1.0" ><br />
<br />
  <xsl:param name="column_name">object_NAME</xsl:param><br />
<br />
  <xsl:template match="/"><br />
    <xsl:value-of select="//table/*[name() = $column_name]/text()"&/><br />
  </xsl:template><br />
<br />
</xsl:stylesheet>


if you don't pass a parameter to your xslt, then it will default to 'object_NAME'.

c# calling code:

XslTransform xslt = new XslTransform();<br />
XmlDocument document = new XmlDocument();<br />
document.LoadXml(xmlFileName);<br />
xslt.Load(stylesheetFileName);<br />
<br />
MemoryStream ms = new MemoryStream();<br />
XPathNavigator nav = document.CreateNavigator();<br />
<br />
XsltArgumentList xslArg = new XsltArgumentList();<br />
<br />
xslArg.AddParam("column_name", "", "name of column you want");<br />
<br />
xslt.Transform(nav, xslArg, ms, null);<br />
<br />
// output to a stream<br />
StreamReader sr = new StreamReader(ms);<br />
ms.Position = 0;<br />
string result = sr.ReadToEnd();<br />
sr.Close();





"When the only tool you have is a hammer, a sore thumb you will have."

GeneralRe: .NET DataSet -&gt; Xml + XSLT -&gt; HTML Pin
dratti9-Jul-03 9:42
dratti9-Jul-03 9:42 
GeneralRe: .NET DataSet -&gt; Xml + XSLT -&gt; HTML Pin
Philip Fitzsimons10-Jul-03 2:47
Philip Fitzsimons10-Jul-03 2:47 
GeneralRe: .NET DataSet -&gt; Xml + XSLT -&gt; HTML Pin
dratti10-Jul-03 4:21
dratti10-Jul-03 4:21 
GeneralXML DOM get current position Node Pin
Anonymous9-Jul-03 0:18
Anonymous9-Jul-03 0:18 
GeneralRe: XML DOM get current position Node Pin
Philip Fitzsimons9-Jul-03 7:10
Philip Fitzsimons9-Jul-03 7:10 
GeneralRe: XML DOM get current position Node Pin
Anonymous10-Jul-03 2:08
Anonymous10-Jul-03 2:08 
GeneralXML Schema Import Pin
Jason Weibel8-Jul-03 8:46
Jason Weibel8-Jul-03 8:46 
GeneralRe: XML Schema Import Pin
Retsof Nawor8-Jul-03 10:14
Retsof Nawor8-Jul-03 10:14 
GeneralRe: XML Schema Import Pin
Jason Weibel8-Jul-03 10:24
Jason Weibel8-Jul-03 10:24 
GeneralRe: XML Schema Import Pin
Jason Weibel8-Jul-03 10:36
Jason Weibel8-Jul-03 10:36 
GeneralRe: XML Schema Import Pin
Retsof Nawor8-Jul-03 10:50
Retsof Nawor8-Jul-03 10:50 
Generalrss file Pin
jphuphilly8-Jul-03 3:52
jphuphilly8-Jul-03 3:52 
Generalchildnodes.length Pin
xaphod5-Jul-03 10:45
xaphod5-Jul-03 10:45 
General&#163; sign in XSL output Pin
autographics4-Jul-03 20:46
autographics4-Jul-03 20:46 
GeneralRe: £ sign in XSL output Pin
Paul Watson6-Jul-03 8:42
sitebuilderPaul Watson6-Jul-03 8:42 
GeneralRe: &#163; sign in XSL output Pin
Philip Fitzsimons7-Jul-03 2:57
Philip Fitzsimons7-Jul-03 2:57 
GeneralXSL Question Please Help Sorry I'm still learning Pin
Gerry Long3-Jul-03 5:47
sussGerry Long3-Jul-03 5:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.