|
I am currently working on an application that uses XML to store it's data. Items are kept in a tree, where the parent child relationships are important. The document looks a lot like this:
<item title="L2" created="10/7/2004 6:48:24 PM" lastModified="10/7/2004 6:48:24 PM" />
<item title="L3" created="10/7/2004 6:48:30 PM" lastModified="10/7/2004 6:48:30 PM">
<item title="L3A" created="10/7/2004 6:49:09 PM" lastModified="10/7/2004 6:49:09 PM" />
<item title="L3B" created="11/14/2004 3:03:02 PM" lastModified="11/14/2004 3:03:02 PM" />
</item>
<item title="L1" created="11/15/2004 9:18:31 PM" lastModified="11/15/2004 9:19:20 PM">
<item title="L1A" created="10/7/2004 6:48:00 PM" lastModified="10/7/2004 6:48:00 PM" />
</item>
What I am looking for is an efficient way to sort the data that maintains parent / child relationships. In other words I want L3A and L3B to be sorted by date only against each other, stay as children of L3.
Any help is greatly appreciated,
Andy
|
|
|
|
|
hmm
insert new nodes in order?
best regards,
David 'DNH' Nohejl
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
As much as I would like that to be the solution, the file is used in conjunction with a handheld device where the data could be created at different times then coppied over and not necesariliy be put in the right place in the file.
-Andy
|
|
|
|
|
hi,
well, I tried;) Load it into memory, sort all childer of parent element and do the same recursively for all childer is probably the most stupid solution, bt only one I can imagine right now. sorry.
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
HI all,
I have an application using ASP.net, and in this application the user will
have the choice to download data from Sql Server to excel sheet,this will be
done using code only
could any one help me how to do this plzzzz???
|
|
|
|
|
Hi friends...
i want to use HTML tags in xml and show them in ASP.net page(by xslt)
first the problem was fixed by this technique in xslt:
(for example <b> tag)
<xsl:template match="b">
<b><xsl:apply-templates /></b>
</xsl:template>
_____________________________________
but when i save the texts that includes html tags it will save with another type in xml file=>
my textbox value that i typed it manually:
<b>hello</b>
and output in xml file:
<b>hello</b>
_____________________________________
now there are 2 way to fix this problem...
i should save the tags with <b> format in xml or shows that correctly with <b>hello</b> format by replace this characters to "<" and ">"
and i dont know how that are possible...i try so much to find my answer buttt... please help me
|
|
|
|
|
I'm trying to transform a C++ data structure into XML format.
Here is my example. I have 2 cars
Red Ford Mustang, black leather interior and Blue VW Bug, white leather interior.
Using the following data structure(s)
struct RGBcolor
{
int R;
int G;
int B;
};
enum Material
{
leather=0,
fabric,
metal
};
struct Interior
{
Material seats;
RGBcolor seatcolor;
};
enum Make
{
Chevy=0,
Ford,
Oldsmobile,
VW
};
enum Style
{
sedan=0,
sport,
suv,
other
};
struct CAR
{
Make carmake;
Style carstyle;
RGBcolor carcolor;
Interior carinterior;
};
How do I turn struct CAR into XML format? What do my tags look like ESPECIALLY the tag for the "car interior?"
What puzzels me is if I can reuse the tag for RGBcolor in both a parent and child node.
Thank you,
Johnny
|
|
|
|
|
[EDIT]The indenting only comes out right in IE - not in Firefox[/EDIT]
You've got a *lot* of freedom with XML. You could do this:
<cars>
<car>
<make>Ford</make>
<model>Mustang</model>
<color R="255" G="0" B="0"/>
<interior>
<color R="0" G="0" B="0"/>
<material>leather</material>
</interior>
</car>
<!-- and do something similar for the VW -->
</cars>
There is no concept of data typing built into XML as it is into C/C++/Java. If you use some form of schema (XML Schemas or DTDs or RelaxNG, for example), you can apply data typing to XML and (with a suitably capable XML processor) validate the XML file against the schema.
For example (and it's quite a big one), here's an XML schema I knocked up in XMLSpy[^] (theres a free download). I've not encoded all your enums and things, but it gives you an idea of what's needed.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="cars">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="car">
<xs:complexType>
<xs:sequence>
<xs:element name="make" type="MakeType"/>
<xs:element name="model"/>
<xs:element name="color" type="ColorType"/>
<xs:element name="interior">
<xs:complexType>
<xs:sequence>
<xs:element name="color" type="ColorType"/>
<xs:element name="material"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="MakeType">
<xs:restriction base="xs:string">
<xs:enumeration value="Chevy"/>
<xs:enumeration value="Ford"/>
<xs:enumeration value="Oldsmobile"/>
<xs:enumeration value="VW"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="ColorType">
<xs:attribute name="R" type="xs:unsignedByte" use="required"/>
<xs:attribute name="G" type="xs:unsignedByte" use="required"/>
<xs:attribute name="B" type="xs:unsignedByte" use="required"/>
</xs:complexType>
</xs:schema>
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Thanks for the help and example. What I want to do is set up a configuration file (similar to the Cars example) that resembles a C++ data structure, and work with that in both C++ and HTML.
On the HTML side, I'm considering an XML approach so that (IF POSSIBLE) I could easily display the structure in HTML-Help, a Help utility/application for VC++ generated applications.
Thanks again,
Johnny
|
|
|
|
|
Sorry for reposting but I had some info screwed up.
Using MSSXL....
After transforming an XML using an XSL I get stuff like this around the resulting text:
<br />
< ? xml version="1.0" encoding="UTF-16" ? ><br />
plus tag attributes like these:
<br />
xmlns:msxsl="urn:schemas-microsoft-com:xslt"<br />
xmlns:us="us"<br />
in elements that are on top level template match.
What are these? How to disable?
Thanks a lot!
|
|
|
|
|
If you're wanting to output text from an XSL, use the XSL output tag, with the method attribute set to 'text'.
If you're outputting XML - you **need** the XML processing instruction to make your output be XML!!!! You can, however, get rid of namespace declarations you don't want by using the exclude-result-prefixes on the stylesheet/transform elements.
HTH
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Using MSSXL....
After transforming an XML using an XSL I get stuff like this around the resulting text:
<br />
<?xml version="1.0" encoding="UTF-16"?><br />
plus tag attributes like these:
<br />
xmlns:msxsl="urn:schemas-microsoft-com:xslt"<br />
xmlns:us="us"<br />
in elements that are on top level template match.
What are these? How to disable?
Thanks a lot!
|
|
|
|
|
Hello, I am using Xerces DOM for C++ in my application. Is there a way to initialize a skeletal DOM object based upon a schema? The Xerces documentation says no to DTD, so I am assuming that transfers over to schemas. Does anyone know if MSXML supports it or any other tool? I was wondering if a tool like XMLSpy will generate a skeletal XML file from a *.xsd schema file? Any help is appreciated -
|
|
|
|
|
XMLSpy will - see my previous answer[^]
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
I have this xml file:
<?xml version="1.0" standalone="yes"?>
<xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="Store3">
<xs:element name="Store3" msdata:IsDataSet="true" msdata:Locale="en-CA">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Associates">
<xs:complexType>
<xs:sequence>
<xs:element name="AssociateId" type="xs:int"/>
<xs:element name="LASTNAME">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="FIRSTNAME">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//Associates"/>
<xs:field xpath="AssociateId"/>
</xs:unique>
</xs:element>
</xs:schema>
How can i get this one?
<xs:element name="Associates">
<xs:complexType>
<xs:sequence>
<xs:element name="AssociateId" type="xs:int"/>
<xs:element name="LASTNAME">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="FIRSTNAME">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
thanx in advance
|
|
|
|
|
Hi, i have this file :
===================
<xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="Store3">
<xs:element name="Store3" msdata:isdataset="true" msdata:locale="en-CA">
<xs:complextype>
<xs:choice maxoccurs="unbounded">
<xs:element name="Associates">
<xs:complextype>
<xs:sequence>
<xs:element name="AssociateId" type="xs:int">
<xs:element name="LASTNAME">
<xs:simpletype>
<xs:restriction base="xs:string">
<xs:maxlength value="50">
<xs:element name="FIRSTNAME">
<xs:simpletype>
<xs:restriction base="xs:string">
<xs:maxlength value="50">
<xs:unique name="Constraint1" msdata:primarykey="true">
<xs:selector xpath=".//Associates">
<xs:field xpath="AssociateId">
===================
So how can i just get this one?
<xs:element name="Associates">
<xs:complextype>
<xs:sequence>
<xs:element name="AssociateId" type="xs:int">
<xs:element name="LASTNAME">
<xs:simpletype>
<xs:restriction base="xs:string">
<xs:maxlength value="50">
<xs:element name="FIRSTNAME">
<xs:simpletype>
<xs:restriction base="xs:string">
<xs:maxlength value="50">
thanx in advance
|
|
|
|
|
Hi there,
On the project I'm currently busy I have the following issue:
We are receiving SOAP 1.1 messages (according to SOAP 1.1 schema) and need to output messages conforming to a schema in another namespace. The structure of both schema's are identical as you can see below.
SOAP schema instance:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<SomeHeader/>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<SomeElement/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Output message schema instance:
<BLA:Envelope xmlns:BLA="http://SomeOtherNamespace">
<BLA:Header>
<SomeHeader/>
</BLA:Header>
<BLA:Body>
<SomeElement/>
</BLA:Body>
</BLA:Envelope>
Okay here the challenge:
We're in need for a high performance transformation of these two messages. The way we would love to see it is having the transform implemented completly streaming.
- input stream read when output stream is being readon (pull).
- low memory footprint.
Environment: C# on .NET platform.
Options I'm considering:
1. Implementing a streaming namespace replacing XML text reader.
A stream is read by a custom XMLTextReader that replaces the xml namespace declaration so the message is implicetly converted.
The problem with this solution is that the streaming XML text reader does not provide a way to generate an output stream. Using the XMLTextWriter object and WriteNode method reads the entire message and puts out the message to the underlying stream. But this is push technology and the process is blocked until the reading and writing is done.
2. Using streaming XSLT (pull)
I have not been able to get this to work. Anybody can give me a hand?
3. Am I overlooking something? Please let me know.
Kind regards for your patience and hopefully a good solution.
Bas
|
|
|
|
|
hello all,
I need to create a XML document say "input.xml" from a XmlSchemaDefinition(input.xsd) document. Kindly tell me how to go about it?
any pointer wud be of utmost help,
thnks
|
|
|
|
|
Downlaod a trial version of XMLSpy[^] - that can generate XML instance documents from XSDs and DTDs.
Make sure it's a trial of the Enterprise or Professional version - the other version doesn't do it.
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
Ok, I know I will get reamed for this XML-newbie question, but here is what I want to know.
Can I have this
<br />
<dataItem_00><br />
<name>somename</name><br />
<type>sometype</type><br />
<br />
<dataItem_01><br />
<name>sub_name_1</name><br />
<type>sub_type_1</type><br />
<dataItem_01><br />
<br />
<dataItem_01><br />
<name>sub_name_2</name><br />
<type>sub_type_2</type><br />
<dataItem_01><br />
</dataItem_00><br />
Basically, I am uncertain about the reuse of tags within nested "blocks"
Thanks,
Johnny
|
|
|
|
|
using dataItem__xx is stupid, but what you're doing is totally legal, that's how you'd have a list of items all the same, which have subitems.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I am gong to nit pic here.
reusing tags is not a problem.
Properly terminating the blocks is and the sample you show does not.
None of your dataItem_01 elements (you have 4 as shown not 2) are terminated.
I do not mind getting old. It beats all the other options that can think of.
|
|
|
|
|
hi sudheer,
is it .NET? If yes, look on System.Xml namespace, expecially classes System.Xml.XmlTextReader or System.Xml.XmlDocument on MSDN.com, there are lot of exmaples how to read XML files.
If it's not .NET, what is it?
best regards,
David 'DNH' Nohejl
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
Hai,
i want to retrive the xml data, i have one xml file, that file contain some data. i want retrive the that data. please givethe procedure how to retrive?
thanks
sudheer
|
|
|
|
|
Hi,
I need an application which displays a tee view of an XML document.
I have seen many applications which do the same. But I need to draw the Tree with the element text and with out attributes node in the tree.
Let me make it clear..
Here is snippet of the xml file.
--------------------------------------------------------------------------------
- <device name="TenGiPHY" deviceversion="1.0.0.1" productid="24622.10.0.1" fileversion="1.0.2.2">
- <group name="PMA/PMD">
- <folder name="MDIO">
- <register name="PMACTR1" length="16" address="0x10000" resetval="0x2040" access="rw">
<longname>PMA Control Register 1
<value>0x0
- <element name="RES" offset="15" length="1">
<longname>PMA reset
<desc>This bit remains set (1) while reset is in progress and is cleared (0) automatically as soon as reset is completed. The first MDIO access following an MDIO reset must be an address frame. Access to this bit affects the entire device.
<modified>false
<state text="Normal operation" value="0x0">
<state text="All registers within the TenGiPHY-L are set to their initial state." value="0x1">
----------------------------------------------------------------------------------------
The tree I need is
TenGiPHY
|
|_PMA/PMD
| |
| |_MDIO
| | |_PMACTR1
| |_NextFolderName
|
|_Next group name
and so on..
But I have the least idea to do this.
Could anyone help me?
Thank you,
|
|
|
|