|
You schema leaves open a few questions on how the elements are hierarchally associated. "ServerName" and "Domain" are not related. Usually, servers are part of domains. Also, "AbuseAddress" is not associated to a "ServerName"! Usually, abuse address attack a certain server. IMHO, your schema design has flaws.
|
|
|
|
|
Hi,
The ServerName used here is the Name of the Whois Server that needs to be queried to obtain the abuse address of the stipulated domain.
When i return XML, i need to mention the name of the whois server(whois.abuse.net) that is being used to get the results, the domain being queried for as well as the result of the query(the abuse address).
Any suggestions on how i could improve my schema would be appreciated.
Thanks.
|
|
|
|
|
I suggest this format because you can record more than one domain and server in one file. Also, this format takes up less space.
<network>
<domain name="domain.com">
<server name="ServerName">
<abuse address="AbuseAddress1" />
<abuse address="AbuseAddress2" />
</server>
</domain>
</network>
|
|
|
|
|
Thanks for ur help.
I read the article u mentioned "Inferring DataSet Relational Structure from XML" and found it very useful. It cleared many of my concepts.
But after reading the article, i found that writing the schema i desired was not possible as i needed to build relations between the heirarchical tables in the schema;
and my schema tables did not have any key in common based on which i could create relations.
I have now used the XmlDocument and XmlNode class in order to write my results directly to an XML file. This is also makes it easier to create nested child nodes.
I appreciate the timely help u have provided.
Thanks.
|
|
|
|
|
Hi,
I am using a dataset which takes its schema from an xsd file that i have created.
The schema comprises nested nodes.
As an example,
<Customers>
<CompanyName>Ana Trujillo Emparedados y helados</CompanyName>
<Orders>
<OrderDate>1996-09-18</OrderDate>
<OrderDetails>
<OrderWeight>20kg</OrderWeight>
<ShipVia>International Air</ShipVia>
</OrderDetails>
</Orders>
</Customers>
Using the above schema, I need to set the values of the OrderDetails node i.e. order weight and shipvia in my dataset using C#.
Any help will be appreciated.
Thanks.
|
|
|
|
|
<Customers>
<CompanyName>Ana Trujillo Emparedados y helados</CompanyName>
<Orders>
<OrderDate>1996-09-18</OrderDate>
<OrderDetails>
<OrderWeight>20kg</OrderWeight>
<ShipVia>International Air</ShipVia>
</OrderDetails>
</Orders>
</Customers>
This won't work as structured. You need something like this:
<Customers>
<Customer>
<CompanyName>Ana Trujillo Emparedados y helados</CompanyName>
<Orders>
<OrderDate>1996-09-18</OrderDate>
<OrderDetails>
<OrderWeight>20kg</OrderWeight>
<ShipVia>International Air</ShipVia>
</OrderDetails>
</Orders>
</Customer>
</Customers>
Also, this is not a schema! The resulting schema with my modification is below. This creates four tables with hierarchal relationships which is usually an result of a JOIN operation on a SELECT relation query.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Customers">
<xs:complexType>
<xs:sequence>
<xs:element name="Customer">
<xs:complexType>
<xs:sequence>
<xs:element name="CompanyName" type="xs:string" />
<xs:element name="Orders">
<xs:complexType>
<xs:sequence>
<xs:element name="OrderDate" type="xs:date" />
<xs:element name="OrderDetails">
<xs:complexType>
<xs:sequence>
<xs:element name="OrderWeight" type="xs:string" />
<xs:element name="ShipVia" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
|
|
|
|
|
Hi,
Thank u George L. Jackson for replying. I have corrected my schema.
The next problem i am facing is that this schema is saved in an XML schema file. I have created a dataset that would load this schema. The columns in my datatable correspond to the nodes above. How do i assign values to the child nodes of the order details node i.e OrderWeight and ShipVia?
DataSet dsRecords = new DataSet();
DataRow newrow = null;
newrow = dsRecords.Tables [ "Customers" ].NewRow( );
newrow["OrderWeight"] = "20kg";
When i try assigning values to these child nodes, it gives me an error that reads: OrderWeight does not belong to my main table. Do i need to create another datatable within the dataset ? How do i proceed?
Thanks.
|
|
|
|
|
Refer to "Inferring DataSet Relational Structure from XML" in the .NET Framework Developer's Guide.
|
|
|
|
|
I am calling datrelation.nested = true.
But I get the error - “Child row has multiple parents"
I am getting this because the dataset contains tables with such data.
E.g. Here is my hierarchy
Operator is parent of OperatorPriviligePair.
OperatorPriviligePair is parent of Privilege
But one privilege can be assigned to may operators. So the problem.
Have you written a method WriteXML to override this?
Or can you walk me through writing my own xml file with my dataset?
I will highly appreciate your help.
Savita
|
|
|
|
|
Hi
It will be helpful if you provide the exact xml format you want.
You can use the XmlTextWriter and loop thru the dataset for creating the exact structure and data.
Gokul
|
|
|
|
|
hi All,
I want to integrate crystal reports into my MFC app. I have already done this using an Access db as a data source. But what I really want to do is to use an XML file as a data source. How do i do this?
I tried to modify the connection string:
// Connection String
_bstr_t bstrAccessConnect ( L"DRIVER={Microsoft Access Driver (*.mdb)};"
L"DBQ=Database.MDB;"
L"DefaultDir=;"
L"UID=admin;PWD=;"
L"Mode=Read;");
but it didnt work. I have configured the ODBC dsn according to the CR XML v3.6 driver. It is correct because I can access the XML file as an ODBC dsn from the Crystal reports manually...So how do i do this in code???
PS: I hav Crystal Reports 8.5
|
|
|
|
|
You'll have to create a connection string that indicates the correct driver and DSN. The Server Explorer in Visual Studio can be helpful in for working out the details.
|
|
|
|
|
I suppose i cant use ADODB connection?(stupid question!)
I tried using ODBC but it didnt work...I am really new to MFC and crystal so i'm completely at a loss...could u pls giv me a sample?
this is what i tried:
CDatabase db;
CRecordset rec(&db);
db.OpenEx("DSN=RGenXML;",0);
CString g_SQLString="SELECT Name FROM Table";
rec.Open(AFX_DB_USE_DEFAULT_TYPE,g_SQLString,CRecordset::none);
The program crashes at this point saying i need to get a licence for my CRXML driver...that doesnt make sense because i can still use it to connect to crystal manually..?!
Please please help!
|
|
|
|
|
If i recall, somewhere, there's a file named IVCR.LIC that you need to have installed in Windows\System in order for this to work. Contact Crystal if you can't find it.
|
|
|
|
|
Hi,
I am trying to update a simple xml file with the following structure, in VB.NET. I am new to XML.
<code><WEIGHTAGES>
<CURRENT>
<P1>10</P1>
<P2>20</P2>
<P3>30</P3>
<P4>40</P4>
</CURRENT>
<PREVIOUS>
<P1>14</P1>
<P2>24</P2>
<P3>45</P3>
<P4>45</P4>
</PREVIOUS>
</WEIGHTAGES></code>
I just want to replace the values in the <code>"<CURRENT>" </code>and <code>"<PREVIOUS>"</code>with new values. No new nodes to be added, just modify these values in VB.NET. Can somebody tell me how to do this?
Abhishek
-- modified at 2:28 Tuesday 14th February, 2006
|
|
|
|
|
You can load the xml in to a XmlDocument object and do the changes
in it by using the Select single node method. And finally save the document.
Gokul
|
|
|
|
|
hi there,
i have 2 functions: the one method (serialize) must create a new xmldocument and call the other method (getxml), which will create and return an xmlnode. the problem is i keep getting the same error message: "The node to be inserted is from a different document context."
i don't want to pass the whole xmldocument to the method because of performance reasons.
here is the code, can anyone help?
public void Serialize()
{
//create xmldoc and call control's getXML method to add their xml to doc
XmlDocument mainDocument = new XmlDocument();
XmlElement rootElement = mainDocument.CreateElement("Root");
mainDocument.AppendChild(rootElement);
XmlNode root = mainDocument.DocumentElement;
foreach (OurTextbox i in this.Controls)
{
mainDocument.AppendChild(i.GetXML());
}
mainDocument.Save("c:\\output.xml");
}
public XmlNode GetXML()
{
XmlDocument doc = new XmlDocument();
XmlElement nameElement = doc.CreateElement(this.Name.ToString());
//create child elements
XmlElement sizeElement = doc.CreateElement("Size");
XmlElement locationElement = doc.CreateElement("Location");
//create size attributes
XmlAttribute widthAttribute = doc.CreateAttribute("Width");
widthAttribute.InnerText = System.Convert.ToString(this.Size.Width);
XmlAttribute heightAttribute = doc.CreateAttribute("Height");
heightAttribute.InnerText = System.Convert.ToString(this.Size.Height);
//create location attributes
XmlAttribute xAttribute = doc.CreateAttribute("X");
xAttribute.InnerText = System.Convert.ToString(this.Location.X);
XmlAttribute yAttribute = doc.CreateAttribute("Y");
yAttribute.InnerText = System.Convert.ToString(this.Location.Y);
//add size attributes to size element
sizeElement.Attributes.Append(widthAttribute);
sizeElement.Attributes.Append(heightAttribute);
//add location attributes to location element
locationElement.Attributes.Append(xAttribute);
locationElement.Attributes.Append(yAttribute);
//add size and location element to name element
nameElement.AppendChild(sizeElement);
nameElement.AppendChild(locationElement);
//rootNode.AppendChild(nameElement);
return nameElement;
}
|
|
|
|
|
Use "ImportNode":
XmlNode newNode = doc.ImportNode(doc2.DocumentElement.LastChild, true);
doc.DocumentElement.AppendChild(newNode);
|
|
|
|
|
Hi All,
I am reading data from SQL Server into a dataset the date format it get into the dataset is same as in the DB(MM/dd/YYYY) but when I use the GetXml() function to get the dataset into string it is changing the date format from “MM/dd/YYYY hh:mm:ss am/pm” (Example: 12/30/2005 12:00:00 AM) to its own format which is “yyyy-MM-ddThh:mm:ss.0000000+03:00 ” (Example: 2005-12-30T00:00:00.0000000+03:00)
Can some body suggest me how can we covert it to the users web culture format or any other user defined format?
|
|
|
|
|
The “yyyy-MM-ddThh:mm:ss.0000000+03:00” format is actually a dateTime.tz data type. It is a subset of the ISO 8601 format with optional time and optional zone. Fractional seconds can be as precise as nanoseconds! Anyway, here is a C++/CLI example to convert this data type into a DateTime variable where the date-time is stored in an attribute called published within an element called book:
<br />
String ^xml = <br />
"<?xml version='1.0'?>"<br />
"<books>"<br />
"<book published='2005-12-30T00:00:00.0000000+03:00'/>"<br />
"<book published='2005-12-30T00:00:00.0000000-05:00'/>"<br />
"</books>"<br />
<br />
XmlDocument ^doc = gcnew XmlDocument();<br />
doc->LoadXml(xml);<br />
<br />
XmlNodeList ^nodes = doc->SelectNodes("/books/book");<br />
<br />
for each (XmlNode ^node in nodes)<br />
{<br />
DateTime published =<br />
XmlConvert::ToDateTime(<br />
node->Attributes->GetNamedItem("published")->Value,<br />
XmlDateTimeSerializationMode::Utc);<br />
<br />
Console::WriteLine(published);<br />
}<br />
|
|
|
|
|
Hi,
Thanks for the reply, Iam getting a dataset from a SQL query and later Iam using the "GetXml()" to get the dataset in a string. in this string I dont know which node has the date, it depends upon the query.
My main issue is first I want to search which node in the string has the date value in this format ( sample date 2006-12-25T16:30:00.0000000+03:00) and then format it as dd/MM/yyyy or any other format.
and more over I am using C# to achive this functionality.
I have modified your code as follows
DataSet myDs = new DataSet();
myDs = myDataset();
string strxml = myDs.GetXml();
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(strxml);
XmlNodeList nodelst = xdoc.SelectNodes("/NewDataSet/Table/StartDate");
foreach (XmlNode node in nodelst)
{
DateTime dt = XmlConvert.ToDateTime(node.InnerText);
Response.Write("Date :" + dt.ToString("dd/MM/yyyy") + "\n");
}
My main concern is in the "xdoc.SelectNodes("/NewDataSet/Table/StartDate");"
I dont want to give the path or the element itself.
I hope I've made my point clear, please feel free if u have any issues
Thanks in Advance
|
|
|
|
|
Please help me... I have a real brain boggler of a problem. This is the code i'm using...
<xsl:template match="TableEndOfDay">
<table border="1" cellspacing="0" cellpadding="1" width="100%">
<tr>
<td>
<table border="1" cellspacing="0" cellpadding="1" width="100%">
<xsl:for-each select="StaffID">
<tr>
<th><font face="Tahoma">hallo</font></th>
</tr>
</xsl:for-each>
</table>
</td>
</tr>
</table>
</xsl:template>
As Soon as i take out the xsl:for-each statement, the "hallo" displays once in the tables.
BUT as soon as i use the code as it is, the only thing showing is the outer tables' border. I need to be able to display the "hallo" once each time for each StaffID. It is quite urgant to me. Please help.....
|
|
|
|
|
You need to post some of the XML you are trying to transform. However, the "StaffID" elements must be child nodes of "TableEndOfDay" in order for the for-each to work as expected. I assume it is finding an empty node-set and the select condition is returning false.
-- modified at 9:54 Friday 10th February, 2006
|
|
|
|
|
Here is a snippet of the XML...
<?xml version="1.0"?>
<?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 xmlns="2">
<StaffName>Pieter</StaffName>
<Services>
<ServiceID xmlns="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>
|
|
|
|
|
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
|
|
|
|