|
Wheatbread wrote: I"m a little confused as to the best practices for creating a schema, particularly, what should be an attribute versus a child element.
Overusage of elements tend to bloat your XML document. I primarily view an element as a hierarchical container of nodes.
Attributes tend to flatten the hierarchy and make your document smaller. I mostly use attributes to uniquely identify and describe an element. However, attributes cannot contain other nodes except for a text node.
How you use elements and attributes is dependent on the data you are trying to represent.
Wheatbread wrote: I also dont know if its best to use global elements and reuse them as child elements or to use a global complexType. Any best practices for this?
You should be aware that a globally defined element can be used as the root element. More than one globally defined element allows a list of roots to choose from. To enforce only one choice of a root element, you must only define one globally and nest all other element declarations into complex type definitions.
Wheatbread wrote: Is it easier programatically to read attributes vs elements using MSXML?
Attributes might be a little easier. Once you have selected an element, the attributes are in name/value pair container off the selected element object.
Wheatbread wrote: Good books on C# and XML?
I cannot really list any books on learning C# or XML since I am not familiar with your background and preferences. I tend to buy reference type books. However, I will list a few web sites that can get you started:
http://www.informit.com/guides/index.asp?rl=1[^]
http://www.w3schools.com/[^]
http://www.topxml.com/[^]
http://www.xml.com/[^]
|
|
|
|
|
Just a few more questions:
So, if I have info that's from a database, probably makes more sense to have elements for a 1:1 relationship w/ the fields of a given record?
My data model is used for communication, serial or network. I have alot of data/value pairs. So I used attributes to describe the value, instead of making alot of elements. For readability, its easier as well. There's a possibility that the data points may be entered into a database, so if I use an XSLT later that I wont have issues w/ linking an attribute to a database field.
I understand the one global element piece, so I removed the other globals elements. I just noticed that an example from another corporate XML communication XSD had multiple globals, and I"m just to figure if I need them.
Thanks again.
-C
|
|
|
|
|
Wheatbread wrote: So, if I have info that's from a database, probably makes more sense to have elements for a 1:1 relationship w/ the fields of a given record?
My data model is used for communication, serial or network. I have alot of data/value pairs. So I used attributes to describe the value, instead of making alot of elements. For readability, its easier as well. There's a possibility that the data points may be entered into a database, so if I use an XSLT later that I wont have issues w/ linking an attribute to a database field.
The usage of elements vs attributes is very subjective. It can be influence by the source and the usage of the output. You can also mix the two together. If you need to change the format of your XML document to meet someone else's needs, you can always transform it via XSLT.
George
|
|
|
|
|
Wheatbread wrote: what should be an attribute versus a child element.
I dont really know what best practices for this are, this is my opinion
Use attributes for what you treat as atomic data, elements for everything that has structure.
Let me explain what I mean when I write "what you treat as..". For example: you have some element representing same thing as record in database, and it has "last modified" attribute. You can view date as NOT atomic. It has attributes "year", "month" etc. You should then have element "last modified" with those attributes, shouldn't you? BUT most probably you use that "last modified" information kind of atomicaly, you always assign\read DateTime object in your code, right. In DB, you have one column of Date type, not columns lastmodifiedday, lastmodifiedmonth, lastmodifiedyear.. Its one value after all. Think of it as number of ticks since 1900 represented as string in dd-mm-yyyy format. Or so.
Umm, now I dunno if my "explanation" did make it clearer
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
I'm not sure I'm following your explanation. My data model is for communication (serial or network), so we matching a database definition isnt as important. But there's a good chance data will eventually be mapped to a database table. So I want to make sure that when we do have to write to a DB that the data model is designed correctly and not complicate things.
-C
|
|
|
|
|
Wheatbread wrote: I'm not sure I'm following your explanation.
No surprise here, I have some difficulties explaining this.
What I was trying to say is that
<file lastModified="22\8\2006" name="file.txt" size="10" />
is ok but
<file name="file.txt" size="10" >
<lastModified>
<day value="22" />
<month value="8" />
<year value="2006" />
</lastModified>
</file>
is probably bad. You can say that day\month\year is VALUE of date, but you cant say it CONTAINS day and month and year, IMO
But
<computer name="myPC">
<disc name="c" >
<folder name="texts">
<file name="text.txt">
</folder>
<folder name="pics">
<file name="image.jpg">
</folder>
<disc name="d" />
</computer>
is better then
<computer name="myPC">
<disc name="c" >
<folder name="texts" files="text.txt;text2.txt" />
<folder name="pics" files="image.jpg;picture.gif" />
<disc name="d" />
</computer>
because when you want to do
<computer name="myPC">
<disc name="c" >
<folder name="texts">
<file name="text.txt" lastModified="8/7/2004">
</folder>
<folder name="pics">
<file name="image.jpg" lastModified="4/3/2006">
</folder>
<disc name="d" />
</computer>
you are screwed in second scenario, because you expected folders to be atomic (csv list of files describes folder) but they suddenly aren't. As in my example with date, if you say VALUE of folder is list of its files (which is retarded idea but its only example of bad practice; best I could think of ) you get the first scenario, but if you realize that folder CONTAINS files you get the second one.
And if there is some flaw in my thinking let me know guys.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
Hi,
As per the three module of development (related to data access from SQL to the front -end and reports on Html)i have developed (ASP.net With c#) n tested it. Its running ok. Speed is also fine as compare to Crystal Report.
Sincearly i have no idea about how the data(format)comes from SQL to the main application.
Is there any better solution,for data transfer in XML . if there is then plzz kindly reply me..
sincerly,
Shriya
|
|
|
|
|
Hi,
I am not very much sure about what your question is.
Do you need to get the data from the database in XML format. Then if you are using Sql Server, try to use FOR XML inn select sql.
Alternatively you can fill data into a dataset and then use that dataset to create a XmlDataDocument. Then if you are using XSLT for your report, then you can make use of the XmlDataDocument.
Pradipta Basu
|
|
|
|
|
Element Nodes in XML file have attributes associated with them.
I randomly select element nodes in an XML document after loading it using DOM class. The selected element node can have zero or more Attributes associated with it.
If selected xml node got attribute I displayed it in ListView.
Attribute Name: Being First ColumnHeader
Attribute Value: Being Second ColumnHeader
Name Item being label of listView can be edited if i enable "labeledit" in property of listView.
But Value under the subitem cannot be edited.
1. How can i simply edit both field using listView?
2. Is there any other control or method that will help me create 2 columns according to number of attributes and enable me to edit fields?
3. How can I edit listBox items? Is there any possibility of using it.
Your reply will be highly appreciated.
Thank you.
Language: Visual C#
|
|
|
|
|
please help me to get some good examples of .xsd file. i need to taks a seminar about this
thankyou
yesuprakash
|
|
|
|
|
Ask google or the search engine of your choice and you will get many answers.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
XPath: /APP/INCOME[@USERID='25']/@Amount
|
|
|
|
|
how to avoid showing coifirm dialog box after editing the xml file through program.
thankyou
Yesuprakash
|
|
|
|
|
ypki wrote: how to avoid showing coifirm dialog box after editing the xml file through program.
Which program are you talking about?
|
|
|
|
|
ctrl-s
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
|
|
|
|
|
Here's a fun little app written in C# using .NET Frameworks 2.0.
See: XML Notepad 2007.
Handy features include:
- Tree View synchronized with Node Text View for quick editing of node names and values.
- Incremental search (Ctrl+I) in both tree and text views, so as you type it navigates to matching nodes.
- Cut/copy/paste with full namespace support.
- Drag/drop support for easy manipulation of the tree, even across different instances of XML Notepad and from the file system.
- Infinite undo/redo for all edit operations.
- In place popup multi-line editing of large text node values.
- Configurable fonts and colors via the options dialog.
- Full find/replace dialog with support for regex and XPath.
- Good performance on large XML documents, loading a 3mb document in about one second.
- Instant XML schema validation while you edit with errors and warnings shown in the task list window.
- Intellisense based on expected elements and attributes and enumerated simple type values.
- Support for custom editors for date, dateTime and time datatypes and other types like color.
- Handy nudge tool bar buttons for quick movement of nodes up and down the tree.
- Inplace HTML viewer for processing xml-stylesheet processing instructions.
- Built-in XML Diff tool.
Enjoy!
Chris Lovett
|
|
|
|
|
In XML Notepad 2007 after loading XML file. If I right click on the attribute in treeView I can add Element "Before" or "After" that attribute node. I don't understand why there is need for this functionality. If we click "Before" on popup menu in elementItem, it adds node under the selected attribute node. If I click on After it adds node under the previously added node.
|
|
|
|
|
HI,
Can anyone tell me how to find whether a tag in Xml file is repeated...(i.e)duplicated.can this be done thru VB.NET coding....
|
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<h1> Time Table</h1>
<xsl:for-each select="TimeTable/Lecture">
<tr>
<td> <xsl:value-of select="CourseTitle"/></td>
<td> <xsl:value-of select="Lecturer"/></td>
<td> <xsl:value-of select="Room"/></td>
<td> <xsl:value-of select="Time"/></td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
This code display the time table . Now I have to apply a check over it.
CHECK: At one time (Time) there would be only one lecture (CourseTitle) in a room, If there are multilple, it should display a message of CLASH.
Can any one tell me how I can embed this logic in XSL sheet?
|
|
|
|
|
Dear,
try to use
<xsl:choose>
<xsl:when test="urcriteria">
code goes here
</xsl:when>
<xsl:otherwise>
code goes here
</xsl:otherwise>
</xsl:when>
Happy Coding
Best Regards,
Haissam Abdul Malak
|
|
|
|
|
Can you please explain us, clearly, what do you intend to do?
|
|
|
|
|
thanq anyway i found the solution
|
|
|
|
|
Hi,
I'm slowly learning enough about xsd to glue my application together.
As part of a message document i have a list of params included in a <params> element
Stage 1
I wrote the schema to hold paramaters containing string types
<param name='foo'>value1</param>
<param name='bar'>value2</param>
that's all good and the schema works
I've now designed the xml for an array element which i would like to use like this:
<param name='foo2'><array dimesions='2'>.....</array></param>
i can't work out how to define the param type to include either text or my own elements. What i really want to do is to say that a param element can contain anything whether text or xml as long as it has a name attribute defined. is xs:group the right way to go? I've tried all sorts of things, I also found xs:any but Stylus Studio won't let me use it anywhere that makes sense for what i am trying to do.
Thanks in advance,
Russell
|
|
|
|
|
Dear All,
I am working with MSXML.
I cant write integer values on XML files as a tag.
Why ?
I want to write integer vaules into XML File.
Kindly Help me.
Thanks.
|
|
|
|
|
The reality of the matter is that XML only knows about strings. What you need to do is convert the integer into a string representations.
|
|
|
|