|
Hi,
below my xml file
- <CateringOrders>
- <orders>
<userid>1</userid>
<orderid>DAK081012093349</orderid>
<Menu>Appetizers</Menu>
<MenuType>Veg</MenuType>
<Region>South-Indian</Region>
<Items>Vankaya Bajji</Items>
<Tray>Half Tray</Tray>
<Qty>12</Qty>
</orders>
- <orders>
<userid>2</userid>
<orderid>DAK081012093811</orderid>
<Menu>Appetizers</Menu>
<MenuType>Veg</MenuType>
<Region>South-Indian</Region>
<Items>Aloo Vada</Items>
<Tray>Half Tray</Tray>
<Qty>18</Qty>
</orders>
- <orders>
<userid>3</userid>
<orderid>DAK081012093811</orderid>
<Menu>Appetizers</Menu>
<MenuType>Veg</MenuType>
<Region>South-Indian</Region>
<Items>Vankaya Bajji</Items>
<Tray>Half Tray</Tray>
<Qty>20</Qty>
</orders>
</CateringOrders>
below auto increment code
Dim xmldoc As New XmlDocument()
Dim Str_XmlFile As String = ""
Str_XmlFile = Server.MapPath("~/CatOrders/") & "CateringOrder.xml"
If Not File.Exists(Str_XmlFile) Then
Dim StrWriter As New XmlTextWriter(Str_XmlFile, System.Text.Encoding.UTF8)
StrWriter.WriteStartDocument(True)
StrWriter.WriteStartElement("CateringOrders")
StrWriter.WriteEndElement()
StrWriter.Close()
End If
xmldoc.Load(Str_XmlFile)
Dim parentelement As XmlElement = xmldoc.CreateElement("orders")
Dim nodes As XmlNodeList = xmldoc.SelectNodes("//orders/userid")
Dim nNodeID As Integer = nodes.Count
nNodeID += 1
Dim userid As XmlElement = xmldoc.CreateElement("userid")
userid.InnerText = nNodeID
Dim orderid As XmlElement = xmldoc.CreateElement("orderid")
orderid.InnerText = Session("orderid")
please let me know how to get last unique id
|
|
|
|
|
I write in c#, but you should be able to use the xpath to get the last unique orderid from your xml.
static void Main(string[] args)
{
XmlDocument doc = new XmlDocument();
doc.Load(@"c:\temp\cateringorders.xml");
string query = "(//orderid[not(orderid=preceding-sibling::orderid)])[last()]";
XmlNodeList nodes = doc.SelectNodes(query);
foreach (XmlNode node in nodes)
{
Console.WriteLine(node.InnerText);
}
Console.WriteLine("Finished");
}
|
|
|
|
|
I used XSD.EXE to convert my schema to a C# class. The tool creates arrays to represent elements whose maxOccurs attribute is unbounded. Arrays are very limiting: you cannot add or delete items without a lot of shuffling.
Has anyone found a way around this limitation of arrays? For simple cases, I have converted the array to a List and back to an array, but that is only useful in the simplest of cases. Perhaps there is another tool that can convert my schema and use a list or some other suitable container (?).
|
|
|
|
|
There is no need for converting the list back to an array, you can replace it. I did that e.g. with GPX files (see also Bernie’s Trackviewer[^] where I use some more tricks for getting "nice" classes from an "ugly" XML schema).
|
|
|
|
|
I am not sure what you mean by "replace it." Do you mean change the implementation of the class produced by XSD.EXE?
My process is:
- convert class array to List (ToList())
- make my changes (add, delete, modify)
- assign back to class array (myList.ToArray)
|
|
|
|
|
Same basic question as the OP.
Looking at your source code it appears that you made manual changes to the generated files? And then fixed the actual serialization problem with XmlElementAttribute?
|
|
|
|
|
|
|
That is precisely what Collections are for -- to address the limitations imposed by fixed length arrays.
The limitation is not on arrays -- it appears to be on how willing programmers are to writing proper code, IMHO.
In C++, the standard library has some things for that, like vectors and maps, and in C# there are collections.
|
|
|
|
|
I think you do not understand the question.
The problem is that the tool (XSD.EXE) generates code that uses arrays. Arrays are limiting since it is difficult to add to or remove items from them. I was looking for another tool (that used a more appropriate collection) or an easy workaround.
Perhaps I could have phrased my question better. The limitation I mentioned was intended to mean that the tool generated arrays, not that of arrays themselves.
Even at this late stage, I appreciate your answer. However, I believe you misread the question.
|
|
|
|
|
I have the following two xml files:
<questionnaire>
<questionnaireid>1</questionnaireid>
<questionnairename>sample questionnaire</questionnairename>
<questions>
<question qid="1" >
<qid>1</qid>
<questiondesc>Q1) Enter some free text</questiondesc>
<typeid>2</typeid>
<required>1</required>
<parentquestion></parentquestion>
</question>
<question qid="2" >
<qid>2</qid>
<questiondesc>Q2) Select any of the choices</questiondesc>
<typeid>6</typeid>
<required>1</required>
<parentquestion></parentquestion>
<choices>
<choice>Choice1</choice>
<choice>Choice2</choice>
<choice>Choice3</choice>
</choices>
</question>
</questions>
</questionnaire>
<questionnaireresponse>
<questionnaireid>1</questionnaireid>
<userid>1234</userid>
<responses>
<response qid="1">
<answers>
<answer>This is some text</answer>
</answers>
</response>
<response qid="2">
<answers>
<answer>Choice 2</answer>
</answers>
</response>
</responses>
</questionnaireresponse>
How do you use xslt to add the response for this user to questionnare file and display as HTML form so in the above example the textbox will be populated with 'This is some text' and the dropdown will have 'Choice 2' selected?
Some example xslt implementing the above would be very helpful to get started. ideally I would like to do this in asp.net
|
|
|
|
|
Appreciate your suggestions to either a book, or an on-line site with tutorials, or whatever. I need to get up-to-speed (from a "cold start") quickly.
best, Bill
The glyphs you are reading now: are place-holders signifying the total absence of a signature.
|
|
|
|
|
Many thanks ! I don't know how I missed noticing that one, since Apress books have generally been very useful to me, and I thought I had searched their site.
best, Bill
It keeps me humble to think there's more bacteria in my gut than neurons in my brain, and that twenty trillion neutrinos pass through one hand a second, and that the average mattress contains 20 million bedbugs each of whom sh*ts once per hour.
|
|
|
|
|
trying to import xml into GPP. Converted .reg to xml but when I import I get the error:
<registry name="clsid=" "="">
An invalid or out of place input element was detected and will be ignored.
I've searched the xml file for that specific line and it doesn't appear. Any idea how to fix this?
|
|
|
|
|
Hi All,
I am trying to create Schema file for xml which looks like a General tree.
My xml will look like
<root>
<node name = "" >
<leaf name = "" value = "" />
</node>
</root>
A node can contain any number of node inside and it goes on.
like
<root>
<node name = "" >
<leaf name = "" value = "" />
</node>
<node name = "" >
<node name = "" >
<leaf name = "" value = "" />
<node name = "" >
<leaf name = "" value = "" />
</node>
</node>
</node>
</root>
Please advice how to create xsd file.
Thanks.
modified 14-Jun-12 13:47pm.
|
|
|
|
|
|
Thanks for your reply.
i was looking for generic xsd not for specific scenario.
i have general Tree having a node which contains some data.
|
|
|
|
|
Above example links were not shared for any specific example. They are for generic design. Reference to start up with.
Don't say, you are expecting an XSD design for your particular tree scenario from us directly!
|
|
|
|
|
Thanks that will be enough.
|
|
|
|
|
Hi All,
Feels good to be a part of this forum of technical stalwarts and Gurus. I feel I will get a solution for my long time problem here .
The problem we are facing here is the performance issues when processing the large XML files. Using Java API transformer factory in interpretive mode takes unbelievable 6 days for processing huge files which is a point of very serious concern in a production system.
Please help me out and do let me know what are the different things required to be attached which will be helpful for the analysis.
|
|
|
|
|
praveen3g wrote: takes unbelievable 6 days for processing huge files
Most people would have figured there was something wrong before this. Take a look at the data you are processing and how you are dealing with it. The chances of anyone being able to guess what is wrong is not very high.
|
|
|
|
|
Hi,
Thanks for the reply.
Answer is no , to the people whom I have checked with was not able to diagnose where the problem is and what is the way around it. Everyone definitely understand that the volume of data in the file is huge , say 100MB xml document but no one till data have given a way to work around it efficiently. Let me know if you wish to have a glance and will look forward to your suggestions
|
|
|
|
|
This is not the sort of issue that can be resolved in a forum like this. You need to do some analysis of your code and measuring of your processing time and code paths. Try running against some small data files and see how long it takes and try to work out whether that is an acceptable length of time.
|
|
|
|
|
I have done my analysis and I guess you do not understand actually what the issue is.Do understand am not a kinder garden student to just post a question and expect a ready made answer as I have done quite a lot of research in it more than you . I will look for someone who can just help me out on what are the different parameters that can be looked for rather than just replying generic. Please do not bother to reply further. Thanks again.
|
|
|
|
|
praveen3g wrote: you do not understand actually what the issue is.
Yes, I understand perfectly: your code runs slow and you want to know why.
praveen3g wrote: I will look for someone who can just help me out on what are the different parameters that can be looked for rather than just replying generic.
Given the information you have provided how can anyone guess what those parameters are?
|
|
|
|