473,383 Members | 1,733 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,383 software developers and data experts.

Is it possible with xerces ?

I try to parse an indented xml file with dom xerces c++.
the file is like that :
<root>
<child1>
<field1> foo </field1>
<field2> bar </field2>
</child1>
<child2>
<field1> foo </field1>
<field2> bar </field2>
</child2>
</root>

where return an white spaces are in the xml file. So the program I
writed with dom give me this tree :
root has five childs :
text-node child1 text-node child2 text-node

the text of the first text-node is "\n "
the text of the second text-node is "\n "
the text of the third text-node is "\n"

these text-node of spaces occurs at each step in the tree hierarchy.

Is it possible to strip these nodes automatically ?

XML standard question : does this xml code respects the xml standard ?

<child2> some text
<field1> foo </field1>
<field2> bar </field2>
</child2>

"some text" is in the same depth of field1 and field2 but is a text. So
there is a soap of text and element. I thougth that the text must be a
leaf of the tree ... So does it respects the standard ?

Thanks

Jul 20 '05 #1
3 1485
Manuel Yguel wrote:
I try to parse an indented xml file with dom xerces c++.
the file is like that :
<root>
<child1>
<field1> foo </field1>
<field2> bar </field2>
</child1>
<child2>
<field1> foo </field1>
<field2> bar </field2>
</child2>
</root>

where return an white spaces are in the xml file. So the program I
writed with dom give me this tree :
root has five childs :
text-node child1 text-node child2 text-node

the text of the first text-node is "\n "
the text of the second text-node is "\n "
the text of the third text-node is "\n"

these text-node of spaces occurs at each step in the tree hierarchy.

Is it possible to strip these nodes automatically ?
yes : there is an option that allows to strip ignorable whitespaces, but
you must give a grammar that defines where are ignorable whitespaces,
like this :

<!ELEMENT root (child1,child2)>

XML standard question : does this xml code respects the xml standard ?

<child2> some text
<field1> foo </field1>
<field2> bar </field2>
</child2>

"some text" is in the same depth of field1 and field2 but is a text. So
there is a soap of text and element. I thougth that the text must be a
leaf of the tree ... So does it respects the standard ?
yes : an element may contain :
-nothing (empty element)
-subelements
-text
-text and subelements

Thanks

--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
Jul 20 '05 #2
Philippe Poulard wrote:
Manuel Yguel wrote:
I try to parse an indented xml file with dom xerces c++.
the file is like that :
<root>
<child1>
<field1> foo </field1>
<field2> bar </field2>
</child1>
<child2>
<field1> foo </field1>
<field2> bar </field2>
</child2>
</root>

where return an white spaces are in the xml file. So the program I
writed with dom give me this tree :
root has five childs :
text-node child1 text-node child2 text-node

the text of the first text-node is "\n "
the text of the second text-node is "\n "
the text of the third text-node is "\n"

these text-node of spaces occurs at each step in the tree hierarchy.

Is it possible to strip these nodes automatically ?

yes : there is an option that allows to strip ignorable whitespaces, but
you must give a grammar that defines where are ignorable whitespaces,
like this :

<!ELEMENT root (child1,child2)>

thanks, but after how do you use the grammar with the parser ?

XML standard question : does this xml code respects the xml standard ?

<child2> some text
<field1> foo </field1>
<field2> bar </field2>
</child2>

"some text" is in the same depth of field1 and field2 but is a text.
So there is a soap of text and element. I thougth that the text must
be a leaf of the tree ... So does it respects the standard ?

yes : an element may contain :
-nothing (empty element)
-subelements
-text
-text and subelements

Thanks



Jul 20 '05 #3
Manuel Yguel wrote:
Philippe Poulard wrote:
Manuel Yguel wrote:
I try to parse an indented xml file with dom xerces c++.
the file is like that :
<root>
<child1>
<field1> foo </field1>
<field2> bar </field2>
</child1>
<child2>
<field1> foo </field1>
<field2> bar </field2>
</child2>
</root>

where return an white spaces are in the xml file. So the program I
writed with dom give me this tree :
root has five childs :
text-node child1 text-node child2 text-node

the text of the first text-node is "\n "
the text of the second text-node is "\n "
the text of the third text-node is "\n"

these text-node of spaces occurs at each step in the tree hierarchy.

Is it possible to strip these nodes automatically ?


yes : there is an option that allows to strip ignorable whitespaces,
but you must give a grammar that defines where are ignorable
whitespaces, like this :

<!ELEMENT root (child1,child2)>

thanks, but after how do you use the grammar with the parser ?


use the <!DOCTYPE> declaration
you should have a look at the spec
--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
Jul 20 '05 #4

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

Similar topics

2
by: Bekkali Hicham | last post by:
hi, i have downloaded the latest version 2.4 of Xerces, and unziped it, i end up with a diectory hierarchy like this c:\xerces-2_4_0\XercesImpl.jar c:\xerces-2_4_0\XercesSamples.jar...
1
by: Stu | last post by:
I am trying to build the xerces shared library with 2.3.0 version of their source code on an AIX 5.1 32 bit machine with the following version of the g++ compiler /usr/local/bin/g++ -v Reading...
0
by: Waseem | last post by:
Hi I have looked and tried everything and i still cant sort this out i have no idea why this wont work I am using Xerces Perl on Windows and Debian to try this and it wont work on both of...
4
by: joes | last post by:
Hello there I tried for several days to get a simple validation with xml schema & xerces working. Goal for me is tuse JAXP and not specific Xerces classes. I don't get the point what I am doing...
0
by: Jim Phelps | last post by:
After having memory leak issues with Xerces-c 2.3.0 for Solaris 2.7 for CC 6.2 I have decided to update to at least 2.4. I have downloaded the binary tarball and have installed it on my...
0
by: Dale Gerdemann | last post by:
I've been trying to use DOM level 3 with xerces-2_6_2. There's a sample called samples/DOM3.java, but I've had trouble with compilation. I've downloaded Xerces-J-bin.2.6.2 and...
18
by: jacksu | last post by:
I have a simple program to run xpath with xerces 1_2_7 XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); XPathExpression xp = xPath.compile(strXpr);...
3
by: Matt | last post by:
Hello, Summary: Where can one download a Xerces-C (XML pardser) dynamic library file (.DLL file) for Windows (Win98/WinNT/Win2k/WinXP/Win2003, including server flavors; don't need to support...
2
by: Vlad Zorinov | last post by:
I'm getting the following error after a couple of months of XML processing, using Xerces 2.0.0 in an apache tomcat. Does anyone have any ideas what this problem may be or what I should do to solve...
3
by: Raphael Tagliani | last post by:
(english version below) Bonjour! Je travaille sur un gros projet java, qui parse beaucoup de fichiers xml au lancement d'un serveur. Nous avons un problème de concurrence qu lancement. En...
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...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.