Groups | Blog | Home
all groups > dotnet xml > january 2006 >

dotnet xml : Confused! Can I create an XML document from an XSD file?



Ray Stevens
1/24/2006 12:42:05 PM
I am confused. I was given a fairly complex xsd schema for use in a project.
When I added this to a website in VS 2005, it shows up in intellesense and I
can instantiate, manipulate it etc. with the following code in the BLL
layer:

public LXML CreateLXML(ref Tsrsubi1.Xormsga2 etx)
{
LXML lxml = new LXML();
DateTime dt = DateTime.Now;
string lenderid = _dal.GetLenderId(etx.orderHeader.custId.ToString());
lxml.Order[0]._ProductType = "TSR";
lxml.Order[0]._OrderRef = etx.orderHeader.orderNo.ToString();
lxml.Status[0].MessageCode = "1050";
lxml.Status[0].MessageTextCode = "QRY";
lxml.Status[0].MessageDesc = "Order Query";
lxml.Request[0].RequestDate = dt.ToString("yy/MM/dd");
lxml.Request[0].ClientTransactionID = etx.clientTransactioId.ToString();
lxml.Request[0].TradingPartnerID = "LAS";
lxml.Request[0].TradingClientID = lenderid +
etx.orderHeader.custId.ToString();
return lxml;
}

When I pass this to a method in the DAL for use in a Web Service call, it
compiles fine as:

public void SendOrderKeyToBizTalk(LXML lxml)
{
XmlDocument xml = new XmlDocument();
xml.Load(lxml.GetXml());
XmlNode node = xml.DocumentElement;
TaxWS.Taxws ws = new TaxWS.TaxCertws();
ws.PortOperation(node);
}

However, I am unable to recognize the LXML when the same XSD file is added
to a class project (as oppossed to Web Site).

The bottom line is I want to be able to use the schema to add values to a
XML document and pass it to the Web Service from a project class... Can I do
this?

RYoung
2/20/2006 2:39:42 PM
I believe dropping the .xsd in a web project will fire off a custom build
provider to compile the .xsd into a typed-dataset class which gives you the
strong typed object shown in your code below. To be able to use that class
in a class library, I believe you'd want to use the xsd.exe tool to generate
the typed dataset and share that library in your solution.

Ron

[quoted text, click to view]

AddThis Social Bookmark Button