"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