473,322 Members | 1,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Xml file written in notepat - very bad idea

Hi!

I have XML document that looks in shortcut like this:


< category >

< block >

< value > 5,234 </ value >

< possible result > 3,9219 </ possible result >

< possible result > 6,28365 </ possible result >

< possible result > 32.768 </ possible result >

</ block >

</ category >

< category >

< block >

< value > 23 </ value >

< possible result > 4345 </ possible result >

< possible result > 637.9 </ possible result >

</ block >

</ category >

< category >

< block >

< value > 2.8 </ value >

< like for > 5,234 </ like for >

</ block >

</ category >
The database is growing and I need tool to manage this.

Is there any programs that helps manage such XML data base. Especially I am
interested in:

Sorting categories blocks by the value in < value > tag, checking syntax.

Thanks for all help

Tedy


Aug 4 '05 #1
4 1204
"Tedy" <su*******@p.pl> wrote in message news:dc**********@news.onet.pl...
Hi!

I have XML document that looks in shortcut like this:


< category >

< block >

< value > 5,234 </ value >

< possible result > 3,9219 </ possible result >

< possible result > 6,28365 </ possible result >

< possible result > 32.768 </ possible result >

</ block >

</ category >

< category >

< block >

< value > 23 </ value >

< possible result > 4345 </ possible result >

< possible result > 637.9 </ possible result >

</ block >

</ category >

< category >

< block >

< value > 2.8 </ value >

< like for > 5,234 </ like for >

</ block >

</ category >
The database is growing and I need tool to manage this.

Is there any programs that helps manage such XML data base. Especially I am interested in:

Sorting categories blocks by the value in < value > tag, checking syntax.


Your first problem would be that the example above is not valid XML:

- Whitespace is not allowed between '<' and the element name in start tags.
See http://www.w3.org/TR/REC-xml/#NT-STag

- Whitespace is not allowed between '</' and the element name in end tags.
See http://www.w3.org/TR/REC-xml/#NT-ETag

- Element names may not contain whitespace.
See http://www.w3.org/TR/REC-xml/#NT-Name

- The document may only have one root element.
See http://www.w3.org/TR/REC-xml/#NT-document
If that is fixed (in this example, I've used hyphens instead of space and
added a 'categories' root element, but you can use whatever you like. I've
also trimmed element content from some whitespace), we get:

<categories>
<category>
<block>
<value>5,234</value>
<possible-result>3,9219</possible-result>
<possible-result>6,28365</possible-result>
<possible-result>32.768</possible-result>
</block>
</category>
<category>
<block>
<value>23</value>
<possible-result>4345</possible-result>
<possible-result>637.9</possible-result>
</block>
</category>
<category>
<block>
<value>2.8</value>
<like-for>5,234</like-for>
</block>
</category>
</categories>

When this is done, we can manipulate it with, for example XSLT, to filter
and sort the information.

In XML, there are at least two levels of syntax checking: a document can be
well formed, or it can be well-formed and valid. The 'fixed' document above
is well-formed as defined in the XML Recommendation
(http://www.w3.org/TR/REC-xml/#dt-wellformed). To be valid the document need
to refer to a DTD and comply with the constraints it expresses
(http://www.w3.org/TR/REC-xml/#dt-valid).

(I've never thought about this, but this means that other brands of schemas,
such as W3C XML Schemas, RELAX NG, and Schematron, has nothing to do with
whether a document is valid or not. Only documents that conform to a DTD can
be valid from an XML 1.0 perspective. Which means that I need to sharpen up
my terminology.)
// Magnus
Aug 4 '05 #2
Hi Tedy,
You can do the sorting using XSLT.

Given this XML file -
<?xml version="1.0"?>
<categories>
<category>
<block>
<value>5234</value>
<possibleresult>39219</possibleresult>
<possibleresult>628365</possibleresult>
<possibleresult>32.768</possibleresult>
</block>
</category >
<category>
<block>
<value>23</value>
<possibleresult>4345</possibleresult>
<possibleresult>637.9</possibleresult>
</block>
</category>
<category>
<block>
<value>2.8</value>
<likefor>5234</likefor>
</block>
</category>
</categories>

The following XSLT stylesheet does sorting -
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" indent="yes" />

<xsl:template match="/categories">
<categories>
<xsl:for-each select="category">
<xsl:sort select="block/value" data-type="number" />
<xsl:copy-of select="." />
</xsl:for-each>
</categories>
</xsl:template>

</xsl:stylesheet>

To manage your XML project, you can use a tool like XML Spy, Stylus
Studio etc.

Regards,
Mukul

Tedy wrote:
Hi!

I have XML document that looks in shortcut like this:


< category >

< block >

< value > 5,234 </ value >

< possible result > 3,9219 </ possible result >

< possible result > 6,28365 </ possible result >

< possible result > 32.768 </ possible result >

</ block >

</ category >

< category >

< block >

< value > 23 </ value >

< possible result > 4345 </ possible result >

< possible result > 637.9 </ possible result >

</ block >

</ category >

< category >

< block >

< value > 2.8 </ value >

< like for > 5,234 </ like for >

</ block >

</ category >
The database is growing and I need tool to manage this.

Is there any programs that helps manage such XML data base. Especially I am
interested in:

Sorting categories blocks by the value in < value > tag, checking syntax.

Thanks for all help

Tedy


Aug 5 '05 #3
Thanks for help :)
Aug 5 '05 #4
Note that you can also easily load this XML into a DataSet and bind it to a
WinForms DataGrid and build you own little "GUI Editor" for editing your
data - or you can bind it to an ASP.NET DataGrid for adding rows and editing
valies in an HTML page.

"Tedy" <su*******@p.pl> wrote in message news:dc**********@news.onet.pl...
Thanks for help :)

Aug 5 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Arnold | last post by:
Is using fseek and ftell a reliable method of getting the file size on a binary file? I thought I remember reading somewhere it wasn't... If not what would be the "right" and portable method to...
6
by: Dan | last post by:
Maybe the title is a little misleading, but I don't know a better way of putting it. What I would like to do, is create a file pointer that really isn't pointing to an actual file on disk, but a...
5
by: Al | last post by:
Hi all We have created a xml file that imports a single project using the Import element. This project compiles to a class library, but has references to two other projects that are also class...
9
by: JimmyKoolPantz | last post by:
IDE: Visual Studio 2005 Language: VB.NET Fox Pro Driver Version: 9.0.0.3504 Problem: I currently have a problem altering a DBF file. I do not get any syntax errors when running the program. ...
9
by: FFMG | last post by:
In my site I have a config table, (MySQL), with about 30 entries; the data is loaded on every single page load. This is not the only call to the db, (we do a total of about 8 calls to the db). As...
3
by: segecko | last post by:
Hi I have a created a custom usercontrol which inherites an Excel like usercontrol. In this usercontrol I have a custom property called SpreadTemplate, which is an enum with (at the moment) two...
14
by: W Marsh | last post by:
Hi. In my application I do something very simple - I open a file, lock it exclusively, write some data to it and close it. If I re-open it in the same process (I mean before the script has...
13
by: swetha | last post by:
HI Every1, I have a problem in reading a binary file. Actually i want a C program which reads in the data from a file which is in binary format and i want to update values in it. The file...
1
by: rocking | last post by:
Hi Guys, I am working to achieve something that lokks really simple , but it actually sint. I have I text tab delimited file. in every line of that file at the same position in every row of the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.