|
XML (Note: I removed "xmlns" and replace it with "id", since no real namespace or valid namespace was defined.):
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="EndOfDayReport.xsl"?>
<EndOfDayReport>
<heading>
<EndOfDayReportOpskrif>End of Day/Month Report</EndOfDayReportOpskrif>
<ReportPeriod>Report Period: 24 November 2005 - 25 November 2005</ReportPeriod>
<DateCreated>Date Created: 2006/02/10 03:43:48 PM</DateCreated>
</heading>
<tableEndOfDay>
<StaffID id="2">
<StaffName>Pieter</StaffName>
<Services>
<ServiceID id="1">
<ServiceKey>BW.1</ServiceKey>
<ServiceDescription>BLOW WAVE - SHORT</ServiceDescription>
<Qty>1</Qty>
<Percent>1%</Percent>
<Amount>140.00</Amount>
</ServiceID>
<ServiceID>
<ServiceKey>BW.2</ServiceKey>
<ServiceDescription>BLOW WAVE - MEDIUM</ServiceDescription>
<Qty>0</Qty>
<Percent>0%</Percent>
<Amount>0</Amount>
</ServiceID>
</Services>
</StaffID>
</tableEndOfDay>
</EndOfDayReport>
XSLT (Note: the main template searches selects the "DocumentElement" and the "for-each" searches its child nodes):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>
<xsl:template match="/EndOfDayReport">
<html>
<head>
<title>Table End of Day</title>
</head>
<body>
<table border="1" cellspacing="0" cellpadding="1" width="100%">
<tr>
<td>
<table border="1" cellspacing="0" cellpadding="1" width="100%">
<xsl:for-each select="tableEndOfDay/StaffID">
<tr>
<th><font face="Tahoma">Hello, <xsl:value-of select="StaffName"/></font></th>
</tr>
</xsl:for-each>
</table>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
-- modified at 15:02 Monday 13th February, 2006
|
|
|
|
|
Thanx, i'll try it. Enjoy your day.
|
|
|
|
|
How does XSLTransform work with the resolver using C#?
Apparantly the TransForm(string input, string output) is obsolute.
must use Transform(stirng input, string output, Resolver resolver)
Have an xml and xsl file which I want to convert to html
Thanks in advance
|
|
|
|
|
You use the XmlResolver to resolve external XML resources such as entities and schemas.
C#:
XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials = CredentialCache.DefaultCredentials;
XslTransform xsl = new XslTransform();
// Use to resolve xsl:import and xsl:include elements
// The resolver is not cached after Load is completed
// If "null", a default resolver is used and exteral resources are not resolved.
// xsl.Load("filename.xsl", null);
xsl.Load("filename.xsl", resolver);
// If "null", a default resolver is used and exteral resources are not resolved.
// xsl.Transform("filename.xml", "filename.htm", null);
xsl.Transform("filename.xml", "filename.htm", resolver);
Note: This information was taken from the .NET Framework Class Library
|
|
|
|
|
Thanx, works like a bomb now. I just don't understand why they made the
xsl:Transform(string,string) obsolute, why not just add the one that includes the resolver?
Anyway, thanx once again.
|
|
|
|
|
Hey Guys need help
Previously i convert a XML File to A String
The String Contain all the information Like "<ns0:Temp><Name><FirstName>Brandon</FirstName></Name></ns0:Temp>"
How can i convert the string back to XML file? Need Help!!
Thanks a million
KaKaShi HaTaKe
KaKaShi HaTaKe
|
|
|
|
|
<br />
XmlDocument xDoc = new XmlDocument();<br />
XmlElement rootElem = xDoc.CreateElement("root");<br />
rootElem.InnerXml= locXml
xDoc.AppendChild(rootElem);<br />
sathy
|
|
|
|
|
You have to account for the namespace in the string!
<br />
String xml = "<?xml version='1.0'?>" +<br />
"<ns0:Temp xmlns:ns0='www.mydomain.com/misc'>...</ns0:Temp>";<br />
<br />
XmlDocument doc = new XmlDocument();<br />
doc.LoadXml(xml);<br />
-- modified at 11:18 Friday 10th February, 2006
|
|
|
|
|
Hi;
I've just started playing with SQLXML 4.0, here is the code which I am using to load the XML into database.
SQLXMLBulkLoad4Class bulkLoad = new SQLXMLBulkLoad4Class();
bulkLoad.ConnectionString = connString;
bulkLoad.BulkLoad = true;
bulkLoad.KeepIdentity = false;
bulkLoad.XMLFragment = true;
bulkLoad.Execute("C:\books.xsd", "C:\books.xml");
My question is that, the mapping file i.e. xsd or booksmapping.xml is compulsory to pass or we can have that information into xml data file? We want to avoid two files to maintain.
Thanks
M. Essa Mughal
Toronto, CANADA
Email: essamughal@yahoo.com
|
|
|
|
|
You can embed the schema in the XML file. However, your XML file increases in size and the schema is harder to maintain since it is embedded into each instance of your books.xml file.
|
|
|
|
|
Hi Jackson;
I am having another problem here. I created the xml file and xsd file using Datatable method WriteXMLSchema and its given schema is not working with SQLXML bulk load.
Here are two Schema:
Working schema which I got from example:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xsd:element name="Book" sql:relation="tblBooks">
<xsd:complextype>
<xsd:sequence>
<xsd:element name="Title" type="xsd:string" sql:field="BookTitle">
<xsd:element name="Publisher" type="xsd:string">
<xsd:element name="DateOfPurchase" type="xsd:date">
Here is the schema which is generated by Datatable method. It is not working with the xml file:
<xs:schema id="Books" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Books" msdata:isdataset="true" msdata:maindatatable="Book" msdata:usecurrentlocale="true">
<xs:complextype>
<xs:choice minoccurs="0" maxoccurs="unbounded">
<xs:element name="Book">
<xs:complextype>
<xs:sequence>
<xs:element name="Row_ID" msdata:readonly="true" msdata:autoincrement="true" type="xs:int">
<xs:element name="BookTitle">
<xs:simpletype>
<xs:restriction base="xs:string">
<xs:maxlength value="100">
<xs:element name="Publisher" minoccurs="0">
<xs:simpletype>
<xs:restriction base="xs:string">
<xs:maxlength value="100">
<xs:element name="DateOfPurchase" type="xs:dateTime" minoccurs="0">
<xs:unique name="Constraint1" msdata:primarykey="true">
<xs:selector xpath=".//Book">
<xs:field xpath="Row_ID">
Any Idea? Is there any particular format for the schema for SQLXML?
Thanks
M. Essa Mughal
Toronto, CANADA
|
|
|
|
|
Unfortunately, I cannot see your information. I haven't worked with SQLXML; however, I believe the schema produced by the DataTable method would be useless in this situation. A schema is a set of rules that describes how XML is structured. Thus, your XML file must have the structure dictated by SQLXML.
Are you using the ExecuteXmlReader method of the ADO.NET SqlCommand object to take a FOR XML result set and moving it directly into a XmlDataDocument object? Using a XmlDataDocument object, you have the advantage of updating your database via a dataset and still have the original XML from the server.
-- modified at 15:53 Friday 10th February, 2006
|
|
|
|
|
Hey,
I want to beable to generate an XML document describing my textbox's properties, button or any other control. Can anyone give me the code or help? I tried to use the System.Xml.Serialize but it says it does not support buttons.gettype method
-- modified at 2:20 Thursday 9th February, 2006
|
|
|
|
|
am using the current code to make my script compatible to firefox and netscape.....but its not workin...can som1 suggest an alternative
if (window.ActiveXObject)
{flag=0;
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load(cool)
if (xmlDoc.parseError.errorCode != 0)
{
var myError = xmlDoc.parseError;
}
else
{
parse1(xmlDoc.documentElement.childNodes(0).text,xmlDoc.documentElement.childNodes(1).text)
}
}
else if(document.implementation && document.implementation.createDocument)
{flag=1;
var xmlDoc=document.implementation.createDocument("","doc",null);
xmlDoc.async=false;
loaded=xmlDoc.load(cool);
if(!loaded)
{
alert("Error");
}
else
{//alert("success")
alert(xmlDoc.documentElement.childNodes.item(1).childNodes.item(0).nodeValue);
xmlDoc.onload=parse1(xmlDoc.documentElement.childNodes.item(1).childNodes.item(0).nodeValue,"http://www-scf.usc.edu/~csci571/2006Spring/hw4/hummer.xml");
}
}
}
function parse1(file1,file2)
{
if(flag==0)
{
var doc=new ActiveXObject("Microsoft.XMLDOM")
doc.async="false"
doc.load(file1)
var doc1=new ActiveXObject("Microsoft.XMLDOM")
doc1.async="false"
doc1.load(file2)
}
else
var xml=document.implementation.createDocument("","doc1",null);
//alert(xml)
xml.async=false;
loaded=xml.load(file1);
var xml1=document.implementation.createDocument("","doc2",null);
xml1.async=false;
loaded2=xml1.load(file2);
|
|
|
|
|
Hello all, i have a windows application which needs a small database (each
record has 7 items) and i am thinking as using xml as database. I will need to
add, delete, update the records (and show them ofcourse in a datagrid). Is there
any documentation (article or sample code) to look at?
Thanks a lot
Knowledge is a power.
|
|
|
|
|
Using xml as database in the simplest sense is basically storing data as text file in xml format (that is, unless you're using SQL Server 2005 to store your xml).
What you need to learn is XPath, and more specifically XQuery. These are comparable to understanding SQL syntax to manipulate database.
The XmlDocument class provides you several functions to load and save text files, and to manipulate xml nodes within.
I believe the ToDoList[^] application in CodeProject uses Xml to store data, if you want to look at a sample project.
Hope that helps
Edbert
Sydney, Australia
"A day without sunshine is like, you know, night."
-- modified at 0:39 Tuesday 7th February, 2006
|
|
|
|
|
|
Hello!!
I have created an XML document programmatically using DOM and MSXML4.
As one of the data items I have added byte data which is actually a processed guid.
Now combination of characters generated as GUID and stored as byte format in the xml document, is shown properly. But for some combination when I open the document it says "An invalid character was found in text content" and the document fails to display any data.
This happens in Windows 2000 and I have seen this once or twice in Windows 2003. The "corrupt" file opens without any problem in Windows XP.
I am using encoding UTF-16.
IE Versions I am using are:
In Windows 2000 6.0.2800.1106 – SP1
In WinXP 6.0.2900.2180 – SP2
Can someone help!!!
Sandeep
|
|
|
|
|
I am trying to figure out how to post a memory buffer which is composed of an XML document, to a ASP page and I am getting a specific error that I am not sure why its throwing. The error is "not all code paths return a value." Below is the code, Is there someone here that can point out my mistake?
Many thanks in advance.
--Derk
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
public class UTSPost
{
private const string BASE_URI = "http://Post/_Update.asp";
public string PostToWS(XmlDocument xmldoc)
{
string uriString = BASE_URI;
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
string postData = xmldoc.ToString();
// Apply ASCII Encoding to obtain the string as a byte array.
byte[] postArray = Encoding.ASCII.GetBytes(postData);
System.Windows.Forms.MessageBox.Show("Uploading data ...");
myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
myWebClient.UseDefaultCredentials = true;
//UploadData implicitly sets HTTP POST as the request method.
byte[] responseArray = myWebClient.UploadData(uriString, postArray);
// Decode and display the response.
//System.Windows.Forms.MessageBox.Show("Response received was :{0}", Encoding.ASCII.GetString(responseArray));
}
}
|
|
|
|
|
From a brief glance your function (public string PostToWS) expects you to return a string, and it does not return anything at all.
At least that's what "not all code paths return a value." usually means.
Edbert
Sydney, Australia
"A day without sunshine is like, you know, night."
|
|
|
|
|
hi guyz,
I need to convert any of the following file formats such as pdf/doc/html to xml in my project using java.
Does anyone know how this can be achieved?
Is there any open source library that can help me?
I searched for FOP(Formatting Objects Processor) but it converts from XML to PDF and not vice versa...
Please help...This is urgent.
Regards,
|
|
|
|
|
Is there a way in an xpath to do a basic IF without using xsl...
This is the query to tell me if there is an update available:
//application[@name="OutlookView"]/version>1
This is the query to tell me the path to the update:
//application[@name="OutlookView"]/url
I would like to merge them if I can, is this possible?
Matthew Hazlett
Sometimes I miss the simpler DOS days of Borland Turbo Pascal (but not very often).
|
|
|
|
|
One way:
//application[@name="OutlookView"]/*[name()='version' or name()='url']
|
|
|
|
|
i have a transformer to convert xml to html.
i have created following xsl.
but when i get the output html the starting table tag (<table>) is missing. the end table tag however appears in the html. What coul be the problem?
<code><?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<xsl:template match="data_table">
<table> <xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="body">
<tr >
<TH valign='top' colspan='3'>
<xsl:apply-templates select="heading"/>
</TH>
<TH valign='top' colspan='3' align='right'>
<xsl:if test = "./link/linkurl and ./link/linktext != ''">
<xsl:element name="A">
<xsl:attribute name="href">
<xsl:value-of select="./link/linkurl"/>
</xsl:attribute>
<xsl:value-of select="./link/linktext"/>
</xsl:element>
</xsl:if>
</TH>
</tr>
</xsl:template> </code>
-- modified at 6:55 Monday 30th January, 2006
|
|
|
|
|
HI
Need Java Code For Validating The XML agaianest XSD which includes other xsd's
|
|
|
|