Oleg Tkachenko [MVP] wrote:
Ben Bloom wrote:
I can see how this is more appropriate, however it doesn't quite solve
my problem. I still get
1BUY as an output from
<BlockTrades xmlns="http://www.macgregor.com/pbws/eod">
<BlockTrade>
<Block_Trade_Id>1</Block_Trade_Id>
<Side>BUY</Side>
</BlockTrade>
</BlockTrades>
I get ID=1, SIDE=BUY
Interesting.
I've attached my code, XSD and XSL files. I'm curious what's different
between either our code, or our environment.
I'm compiling with VS.NET 2003 on Win2kSP4
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.Schema;
using System.Xml.XPath;
using System.IO;
namespace xslt_test
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox input;
private System.Windows.Forms.TextBox output;
private System.Windows.Forms.Button button1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
input.Text = "<BlockTrades xmlns=\"http://www.macgregor.com/pbws/eod\">\r\n" +
"<BlockTrade>\r\n" +
"\t<Block_Trade_Id>1</Block_Trade_Id>\r\n" +
"\t<Side>BUY</Side>\r\n" +
"</BlockTrade>\r\n" +
"</BlockTrades>\r\n";
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.input = new System.Windows.Forms.TextBox();
this.output = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// input
//
this.input.Location = new System.Drawing.Point(8, 8);
this.input.Multiline = true;
this.input.Name = "input";
this.input.Size = new System.Drawing.Size(664, 168);
this.input.TabIndex = 0;
this.input.Text = "";
//
// output
//
this.output.Location = new System.Drawing.Point(8, 184);
this.output.Multiline = true;
this.output.Name = "output";
this.output.Size = new System.Drawing.Size(664, 192);
this.output.TabIndex = 1;
this.output.Text = "";
//
// button1
//
this.button1.Location = new System.Drawing.Point(16, 384);
this.button1.Name = "button1";
this.button1.TabIndex = 2;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(680, 677);
this.Controls.Add(this.button1);
this.Controls.Add(this.output);
this.Controls.Add(this.input);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
DataSet Trades = new DataSet();
Trades.ReadXmlSchema("BlockTrades.xsd");
Trades.ReadXml(new StringReader(input.Text));
XmlDataDocument xmlDoc = new XmlDataDocument(Trades);
XslTransform xslt = new XslTransform();
xslt.Load("PBWS.EOD.xsl");
StringWriter sw = new StringWriter();
xslt.Transform(xmlDoc, null, sw, null);
output.Text = sw.ToString();
}
}
}