Click here to Skip to main content
15,913,854 members
Home / Discussions / XML / XSL
   

XML / XSL

 
QuestionHTML Table in XML Comment ? Pin
Ariston Darmayuda8-Aug-06 6:32
Ariston Darmayuda8-Aug-06 6:32 
AnswerRe: HTML Table in XML Comment ? Pin
Dustin Metzgar8-Aug-06 6:56
Dustin Metzgar8-Aug-06 6:56 
QuestionXML Parsing and XPath [modified] Pin
bemahesh8-Aug-06 4:22
bemahesh8-Aug-06 4:22 
QuestionApplying conditions in XSD Pin
azam3167-Aug-06 1:57
azam3167-Aug-06 1:57 
Questionxhtml 1.0 transitional / javascript enabled? Pin
matthias s.4-Aug-06 13:02
matthias s.4-Aug-06 13:02 
AnswerRe: xhtml 1.0 transitional / javascript enabled? Pin
eggie55-Aug-06 21:09
eggie55-Aug-06 21:09 
GeneralRe: xhtml 1.0 transitional / javascript enabled? Pin
matthias s.6-Aug-06 1:38
matthias s.6-Aug-06 1:38 
Question1st stab at xsl Pin
Malcolm Smart4-Aug-06 2:10
Malcolm Smart4-Aug-06 2:10 
Hi
I am now using xlst to write out my xml doc as a HTML string instead of using selectnode etc. It's neat. But....I can't work out how to specify search criteria for the xml doc. I just get it all. Sample below :-

XML DOC

<Fields>
<BatchParam name="Field 1" tab="Tab 1" Seq="1" />
<BatchParam name="Field 2" tab="Tab 1" Seq="3" />
<BatchParam name="Field 3" tab="Tab 1" Seq="2" />
<BatchParam name="Field 1" tab="Tab 2" Seq="1" />
<BatchParam name="Field 2" tab="Tab 2" Seq="3" />
<BatchParam name="Field 3" tab="Tab 2" Seq="2" />
<BatchParam name="Field 1" tab="Tab 3" Seq="1" />
</Fields>

I want to display a specific tab, eg Tab 2 in a table, ordered by seq

My XSL
<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match='/ | @* | node()'>
<xsl:copy>
<xsl:apply-templates select="node()">
<xsl:sort select='@seq'/>
</xsl:apply-templates>
</xsl:copy>
<tr>
<td>
<xsl:value-of select='position()'/>
</td>
<td>
<xsl:value-of select='@tab'/>
</td>
<td>
<xsl:value-of select='@name'/>
</td>
<td>
<xsl:value-of select='@seq'/>
<br/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>

and finally my C# code

System.IO.StringWriter objStream = new System.IO.StringWriter();

System.Xml.Xsl.XslTransform objTransform = new System.Xml.Xsl.XslTransform();

objTransform.Load(madconfig.Config.Get("MYXSLFILE.XSL"));

System.Xml.XPath.XPathDocument xml = new System.Xml.XPath.XPathDocument("MYXMLFILE.XML");
System.Xml.XPath.XPathNavigator xmlNav = xml.CreateNavigator();

objTransform.Transform(xmlNav, null, objStream, null);
Response.Write ("<table border=1>"+objStream.ToString()+"</table>");

And this displays ALL the entries. Before, rolling my own I did something like

string tabName = GetTabName();
System.Xml.XPath.XPathExpression expr = xmlNav.Compile("/Fields/BatchParam[@name=\""+tabName+"\"]");
System.Xml.XPath.XPathNodeIterator iterator = xmlNav.Select(expr);

Any ideas...?




Regards

Angel
*********************************************
The sooner you fall behind, the longer you have to catch up.

AnswerRe: 1st stab at xsl Pin
Malcolm Smart4-Aug-06 3:20
Malcolm Smart4-Aug-06 3:20 
GeneralRe: 1st stab at xsl Pin
Dustin Metzgar4-Aug-06 4:21
Dustin Metzgar4-Aug-06 4:21 
GeneralRe: 1st stab at xsl Pin
Malcolm Smart4-Aug-06 4:39
Malcolm Smart4-Aug-06 4:39 
GeneralRe: 1st stab at xsl Pin
Dustin Metzgar4-Aug-06 5:13
Dustin Metzgar4-Aug-06 5:13 
GeneralRe: 1st stab at xsl Pin
Malcolm Smart4-Aug-06 5:33
Malcolm Smart4-Aug-06 5:33 
GeneralRe: 1st stab at xsl Pin
Malcolm Smart4-Aug-06 5:39
Malcolm Smart4-Aug-06 5:39 
GeneralRe: 1st stab at xsl Pin
Dustin Metzgar4-Aug-06 5:49
Dustin Metzgar4-Aug-06 5:49 
QuestionNeed Complete reference on XPath Pin
Rizwan Bashir3-Aug-06 23:36
Rizwan Bashir3-Aug-06 23:36 
AnswerRe: Need Complete reference on XPath Pin
Dustin Metzgar4-Aug-06 4:24
Dustin Metzgar4-Aug-06 4:24 
QuestionHow to match several different elements in the middle of XPath? Pin
CherezZaboro3-Aug-06 9:46
CherezZaboro3-Aug-06 9:46 
AnswerRe: How to match several different elements in the middle of XPath? Pin
Erik Molenaar8-Aug-06 5:08
Erik Molenaar8-Aug-06 5:08 
QuestionPage width in xsl Pin
Support1232-Aug-06 22:31
Support1232-Aug-06 22:31 
AnswerRe: Page width in xsl Pin
Support1232-Aug-06 22:52
Support1232-Aug-06 22:52 
QuestionRe: Page width in xsl I WAS WRONG Pin
Support1233-Aug-06 0:09
Support1233-Aug-06 0:09 
AnswerRe: Page width in xsl I WAS WRONG Pin
Dustin Metzgar3-Aug-06 6:27
Dustin Metzgar3-Aug-06 6:27 
QuestionXPath syntax to find all nodes that don't have some attribute at all? [modified] Pin
CherezZaboro1-Aug-06 6:41
CherezZaboro1-Aug-06 6:41 
AnswerRe: XPath syntax to find all nodes that don't have some attribute at all? Pin
Dustin Metzgar1-Aug-06 7:36
Dustin Metzgar1-Aug-06 7:36 

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.