You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Javier Gálvez Guerrero <du...@gmail.com> on 2007/11/27 09:24:25 UTC

How to parse using DOM

Hi,

I am a complete newbie and I would like to get some help from the people
used to Xerces C++ or anybody who could help me.

I want to parse XML files into a C++ structure using DOM representation. I
know that with SAX, in order to parse the files, startElement, endElement and
characters interfaces can be overriden and told what to do depending on the
read tag. I have searched for similar information, if the same interface
must be overriden when using DOM or which methods I should override or
create, but I have not found anything.

I would like someone to tell me briefly (or as deep as you want/can...) what
I should do.


Thanks a lot, your help is much appreciated,

Javi

Re: How to parse using DOM

Posted by Sven Bauhan <sv...@ast.dfs.de>.
> //get the DOM representation
> DOMNode *doc = parser->getDocument();
>
> I can not find the getDocument method description in the provided
> documentation and I am quite confused about it. Anyway, *doc is supposed to
> be the DOM representation. So, what I need to do is to extract many
> elements (with their childs and attributes) from a XML file, which is
> supposed to be represented by *doc once it has been parsed and got. Then,
> how can I assign, let's say, the value of the "nickname" element inside its
> parent element "user"? getDocument returns the root node? So I guess I can
> ask it for its children and then "move" through the tree with methods of
> the DOMNode API, like for example, getNodeValue(), getChildNodes() and so
> on.
>
This is just the way I use it too. For the interface of the DOM classes 
http://xerces.apache.org/xerces-c/ApacheDOMC++BindingL2.html is quite useful.

As far as I know it should also be possible to use XPath to navigate through 
the element structure. But I did not find out yet how this could be done.

Sven

Re: How to parse using DOM

Posted by David Bertoni <db...@apache.org>.
Javier Gálvez Guerrero wrote:
> Nice!! Thanks a lot! Your approach is quite interesting; I'll see if it
> meets my requirements.
> 
> I thought that XMLSize_t could not be treated as an index (as a common
> integer). That known I can continue coding.
XMLSize_t is just a convenient typedef for the appropriate built-in 
integral type for the compiler and platform.

Please make sure you review the DOM samples for more information about 
using the APIs.  In particular, I suggest you consider using 
DOMNode::getNextChild() and DOMNode::getNextSibling() to walk the children 
of an element, if you care about efficiency.

Dave

Re: How to parse using DOM

Posted by Javier Gálvez Guerrero <du...@gmail.com>.
Nice!! Thanks a lot! Your approach is quite interesting; I'll see if it
meets my requirements.

I thought that XMLSize_t could not be treated as an index (as a common
integer). That known I can continue coding.

Cheers,
Javi


2007/11/27, Jesse Pelton <js...@pkc.com>:
>
> Why do you need an integer?  You can just as easily loop on an XMLSize_t
> value:
>
>   DOMNodeList *child_contents = root.getChildNodes();
>   for (XMLSize_t index = 0; index < child_contents.getLength(); index++)
>   {
>     DOMNode * child = child_contents[index];
>
>     // do something useful
>   }
>
> I show child_contents.getLength() being tested in the for() statement
> because DOMNodeLists are "live" and can change length if nodes are added or
> removed in the loop.  If you know for sure that your DOM won't change during
> processing, you can record the list's length outside the loop and save a
> function call on each iteration.  If the DOM can change, odds are that my
> simple-minded defensive code will just be the starting point for the code
> you'll need to handle the changes.  For instance, if you add a single node
> prior to the one you're currently processing, the "next" node you fetch will
> be the same as the current one unless you increment the index to take the
> addition into account.
>
> But I use a different approach, as I suspect most other people do:
>
>   DOMNode * child;
>   for (child =  root->getFirstChild();
>        child != NULL;
>        child =  child->getNextSibling())
>   {
>     // do something useful
>   }
>
> This approach saves the time and space necessary used to create the
> DOMNodeList.  Since this sort of processing is often recursive, any
> optimization will be multiplied.  At least as important, I also find this
> easier to understand, so I'm more likely to get it right (or to notice if I
> haven't).  It assumes that the object pointed to by "child" is never removed
> while it is being processed.  If removal is possible, you'll need to fetch
> the next sibling before the child is removed.
>
> -----Original Message-----
> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
> Sent: Tuesday, November 27, 2007 1:09 PM
> To: c-users@xerces.apache.org
> Subject: Re: How to parse using DOM
>
> Thank you again for all your answers. I hope you are not fed up with me
> yet..haha.
>
> Now I want to obtain an int (c++) in order to process all the children of
> the root node in the DOM representation, so:
>
> DOMNodeList *child_contents = root.getChildNodes();
>
> With child_contents.getLength() I have a XMLSize_t value as a result. How
> can I parse it to a int?
>
> Thank you a lot again,
> Javi
>
>
> 2007/11/27, Jesse Pelton <js...@pkc.com>:
> >
> > http://xerces.apache.org/xerces-c/apiDocs/functions_0x67.html provides a
> > list of methods implemented by Xerces-C; if you look at it, you'll find
> > getDocument() is a method of AbstractDOMParser.  Click the method name
> and
> > you'll find a brief description, including the fact that it returns a
> > DOMDocument pointer. Click DOMDocument and you'll find that it has a
> > getDocumentElement() method "that allows direct access to the child node
> > that is the root element of the document."  Given this node, you can use
> > getChildNodes(), getFirstChild(), getNextSibling(), and so on to
> directly
> > navigate the DOM.
> >
> > Alternately, you can use getElementsByTagName() to obtain a list of
> > elements with a given name or getElementById() to get an element with a
> > unique ID.  Or use DOMTreeWalker to work with a subset of your
> > document.  I've never done that, so it's left as an exercise for the
> > student.
> >
> > -----Original Message-----
> > From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
> > Sent: Tuesday, November 27, 2007 10:46 AM
> > To: c-users@xerces.apache.org
> > Subject: Re: How to parse using DOM
> >
> > Thank you all very much, specially to Sven who shared his own effort.
> >
> > However, I have looked into the samples on the repositories site and I
> > can't
> > find how to "extract" the data itself from the DOM tree. If you don't
> mind
> > I
> > would like to make some simple questions so with your answers I hope I
> > could
> > start typing code.
> >
> > //get the DOM representation
> > DOMNode *doc = parser->getDocument();
> >
> > I can not find the getDocument method description in the provided
> > documentation and I am quite confused about it. Anyway, *doc is supposed
> > to
> > be the DOM representation. So, what I need to do is to extract many
> > elements
> > (with their childs and attributes) from a XML file, which is supposed to
> > be
> > represented by *doc once it has been parsed and got. Then, how can I
> > assign,
> > let's say, the value of the "nickname" element inside its parent element
> > "user"? getDocument returns the root node? So I guess I can ask it for
> its
> > children and then "move" through the tree with methods of the DOMNode
> API,
> > like for example, getNodeValue(), getChildNodes() and so on.
> >
> > Is it ok? Does it exist any other way to extract data from the DOM
> > representation or this is the one about to use?
> >
> > Thank you all very much again and sorry for the inconvenience. I am
> really
> > interested in using Xerces in the application I am developing, so that's
> > whay I would like to know how to use it properly.
> >
> > Cheers,
> > Javi
> >
> > **
> >
> >
> >
> > 2007/11/27, David Bertoni <db...@apache.org>:
> > >
> > > Sven Bauhan wrote:
> > > > Hi Javi,
> > > >
> > > > the Xerces interface is not really intuitively. A short description
> > can
> > > be
> > > > found at the DOM programming giude:
> > > > http://xerces.apache.org/xerces-c/program.html
> > > >
> > > > In the Xerces documentation it is often described to use an extra
> > class
> > > for
> > > > the conversion of std::string and XMLChar*. I have written such a
> > class.
> > > As
> > > > it is quite short, I attach it here.
> > > Your class uses XMLString::transcode(), which transcodes to the local
> > code
> > > page.  This will result in data loss in cases where content contains
> > > Unicode characters that are not representable in the local code
> page.  A
> > > better choice would be to transcode to UTF-8, which is compatible with
> > > char* APIs, and has the advantage that it can represent any Unicode
> > > character.
> > >
> > > There are many postings in the archives that will illustrate why using
> > > XMLString::transcode() is a bad idea.  I wish we would actually modify
> > the
> > > analogous class in our samples so it doesn't do local code page
> > > transcoding, as it's providing a bad example.
> > >
> > > Dave
> > >
> >
>

RE: How to parse using DOM

Posted by Jesse Pelton <js...@PKC.com>.
Why do you need an integer?  You can just as easily loop on an XMLSize_t value:

  DOMNodeList *child_contents = root.getChildNodes();
  for (XMLSize_t index = 0; index < child_contents.getLength(); index++)
  {
    DOMNode * child = child_contents[index];

    // do something useful
  }

I show child_contents.getLength() being tested in the for() statement because DOMNodeLists are "live" and can change length if nodes are added or removed in the loop.  If you know for sure that your DOM won't change during processing, you can record the list's length outside the loop and save a function call on each iteration.  If the DOM can change, odds are that my simple-minded defensive code will just be the starting point for the code you'll need to handle the changes.  For instance, if you add a single node prior to the one you're currently processing, the "next" node you fetch will be the same as the current one unless you increment the index to take the addition into account.

But I use a different approach, as I suspect most other people do:

  DOMNode * child;
  for (child =  root->getFirstChild();
       child != NULL;
       child =  child->getNextSibling())
  {
    // do something useful
  }

This approach saves the time and space necessary used to create the DOMNodeList.  Since this sort of processing is often recursive, any optimization will be multiplied.  At least as important, I also find this easier to understand, so I'm more likely to get it right (or to notice if I haven't).  It assumes that the object pointed to by "child" is never removed while it is being processed.  If removal is possible, you'll need to fetch the next sibling before the child is removed.

-----Original Message-----
From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com] 
Sent: Tuesday, November 27, 2007 1:09 PM
To: c-users@xerces.apache.org
Subject: Re: How to parse using DOM

Thank you again for all your answers. I hope you are not fed up with me
yet..haha.

Now I want to obtain an int (c++) in order to process all the children of
the root node in the DOM representation, so:

DOMNodeList *child_contents = root.getChildNodes();

With child_contents.getLength() I have a XMLSize_t value as a result. How
can I parse it to a int?

Thank you a lot again,
Javi


2007/11/27, Jesse Pelton <js...@pkc.com>:
>
> http://xerces.apache.org/xerces-c/apiDocs/functions_0x67.html provides a
> list of methods implemented by Xerces-C; if you look at it, you'll find
> getDocument() is a method of AbstractDOMParser.  Click the method name and
> you'll find a brief description, including the fact that it returns a
> DOMDocument pointer. Click DOMDocument and you'll find that it has a
> getDocumentElement() method "that allows direct access to the child node
> that is the root element of the document."  Given this node, you can use
> getChildNodes(), getFirstChild(), getNextSibling(), and so on to directly
> navigate the DOM.
>
> Alternately, you can use getElementsByTagName() to obtain a list of
> elements with a given name or getElementById() to get an element with a
> unique ID.  Or use DOMTreeWalker to work with a subset of your
> document.  I've never done that, so it's left as an exercise for the
> student.
>
> -----Original Message-----
> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
> Sent: Tuesday, November 27, 2007 10:46 AM
> To: c-users@xerces.apache.org
> Subject: Re: How to parse using DOM
>
> Thank you all very much, specially to Sven who shared his own effort.
>
> However, I have looked into the samples on the repositories site and I
> can't
> find how to "extract" the data itself from the DOM tree. If you don't mind
> I
> would like to make some simple questions so with your answers I hope I
> could
> start typing code.
>
> //get the DOM representation
> DOMNode *doc = parser->getDocument();
>
> I can not find the getDocument method description in the provided
> documentation and I am quite confused about it. Anyway, *doc is supposed
> to
> be the DOM representation. So, what I need to do is to extract many
> elements
> (with their childs and attributes) from a XML file, which is supposed to
> be
> represented by *doc once it has been parsed and got. Then, how can I
> assign,
> let's say, the value of the "nickname" element inside its parent element
> "user"? getDocument returns the root node? So I guess I can ask it for its
> children and then "move" through the tree with methods of the DOMNode API,
> like for example, getNodeValue(), getChildNodes() and so on.
>
> Is it ok? Does it exist any other way to extract data from the DOM
> representation or this is the one about to use?
>
> Thank you all very much again and sorry for the inconvenience. I am really
> interested in using Xerces in the application I am developing, so that's
> whay I would like to know how to use it properly.
>
> Cheers,
> Javi
>
> **
>
>
>
> 2007/11/27, David Bertoni <db...@apache.org>:
> >
> > Sven Bauhan wrote:
> > > Hi Javi,
> > >
> > > the Xerces interface is not really intuitively. A short description
> can
> > be
> > > found at the DOM programming giude:
> > > http://xerces.apache.org/xerces-c/program.html
> > >
> > > In the Xerces documentation it is often described to use an extra
> class
> > for
> > > the conversion of std::string and XMLChar*. I have written such a
> class.
> > As
> > > it is quite short, I attach it here.
> > Your class uses XMLString::transcode(), which transcodes to the local
> code
> > page.  This will result in data loss in cases where content contains
> > Unicode characters that are not representable in the local code page.  A
> > better choice would be to transcode to UTF-8, which is compatible with
> > char* APIs, and has the advantage that it can represent any Unicode
> > character.
> >
> > There are many postings in the archives that will illustrate why using
> > XMLString::transcode() is a bad idea.  I wish we would actually modify
> the
> > analogous class in our samples so it doesn't do local code page
> > transcoding, as it's providing a bad example.
> >
> > Dave
> >
>

Re: How to parse using DOM

Posted by Javier Gálvez Guerrero <du...@gmail.com>.
Thank you again for all your answers. I hope you are not fed up with me
yet..haha.

Now I want to obtain an int (c++) in order to process all the children of
the root node in the DOM representation, so:

DOMNodeList *child_contents = root.getChildNodes();

With child_contents.getLength() I have a XMLSize_t value as a result. How
can I parse it to a int?

Thank you a lot again,
Javi


2007/11/27, Jesse Pelton <js...@pkc.com>:
>
> http://xerces.apache.org/xerces-c/apiDocs/functions_0x67.html provides a
> list of methods implemented by Xerces-C; if you look at it, you'll find
> getDocument() is a method of AbstractDOMParser.  Click the method name and
> you'll find a brief description, including the fact that it returns a
> DOMDocument pointer. Click DOMDocument and you'll find that it has a
> getDocumentElement() method "that allows direct access to the child node
> that is the root element of the document."  Given this node, you can use
> getChildNodes(), getFirstChild(), getNextSibling(), and so on to directly
> navigate the DOM.
>
> Alternately, you can use getElementsByTagName() to obtain a list of
> elements with a given name or getElementById() to get an element with a
> unique ID.  Or use DOMTreeWalker to work with a subset of your
> document.  I've never done that, so it's left as an exercise for the
> student.
>
> -----Original Message-----
> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
> Sent: Tuesday, November 27, 2007 10:46 AM
> To: c-users@xerces.apache.org
> Subject: Re: How to parse using DOM
>
> Thank you all very much, specially to Sven who shared his own effort.
>
> However, I have looked into the samples on the repositories site and I
> can't
> find how to "extract" the data itself from the DOM tree. If you don't mind
> I
> would like to make some simple questions so with your answers I hope I
> could
> start typing code.
>
> //get the DOM representation
> DOMNode *doc = parser->getDocument();
>
> I can not find the getDocument method description in the provided
> documentation and I am quite confused about it. Anyway, *doc is supposed
> to
> be the DOM representation. So, what I need to do is to extract many
> elements
> (with their childs and attributes) from a XML file, which is supposed to
> be
> represented by *doc once it has been parsed and got. Then, how can I
> assign,
> let's say, the value of the "nickname" element inside its parent element
> "user"? getDocument returns the root node? So I guess I can ask it for its
> children and then "move" through the tree with methods of the DOMNode API,
> like for example, getNodeValue(), getChildNodes() and so on.
>
> Is it ok? Does it exist any other way to extract data from the DOM
> representation or this is the one about to use?
>
> Thank you all very much again and sorry for the inconvenience. I am really
> interested in using Xerces in the application I am developing, so that's
> whay I would like to know how to use it properly.
>
> Cheers,
> Javi
>
> **
>
>
>
> 2007/11/27, David Bertoni <db...@apache.org>:
> >
> > Sven Bauhan wrote:
> > > Hi Javi,
> > >
> > > the Xerces interface is not really intuitively. A short description
> can
> > be
> > > found at the DOM programming giude:
> > > http://xerces.apache.org/xerces-c/program.html
> > >
> > > In the Xerces documentation it is often described to use an extra
> class
> > for
> > > the conversion of std::string and XMLChar*. I have written such a
> class.
> > As
> > > it is quite short, I attach it here.
> > Your class uses XMLString::transcode(), which transcodes to the local
> code
> > page.  This will result in data loss in cases where content contains
> > Unicode characters that are not representable in the local code page.  A
> > better choice would be to transcode to UTF-8, which is compatible with
> > char* APIs, and has the advantage that it can represent any Unicode
> > character.
> >
> > There are many postings in the archives that will illustrate why using
> > XMLString::transcode() is a bad idea.  I wish we would actually modify
> the
> > analogous class in our samples so it doesn't do local code page
> > transcoding, as it's providing a bad example.
> >
> > Dave
> >
>

RE: How to parse using DOM

Posted by Jesse Pelton <js...@PKC.com>.
http://xerces.apache.org/xerces-c/apiDocs/functions_0x67.html provides a list of methods implemented by Xerces-C; if you look at it, you'll find getDocument() is a method of AbstractDOMParser.  Click the method name and you'll find a brief description, including the fact that it returns a DOMDocument pointer. Click DOMDocument and you'll find that it has a getDocumentElement() method "that allows direct access to the child node that is the root element of the document."  Given this node, you can use getChildNodes(), getFirstChild(), getNextSibling(), and so on to directly navigate the DOM.  

Alternately, you can use getElementsByTagName() to obtain a list of elements with a given name or getElementById() to get an element with a unique ID.  Or use DOMTreeWalker to work with a subset of your document.  I've never done that, so it's left as an exercise for the student. 

-----Original Message-----
From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com] 
Sent: Tuesday, November 27, 2007 10:46 AM
To: c-users@xerces.apache.org
Subject: Re: How to parse using DOM

Thank you all very much, specially to Sven who shared his own effort.

However, I have looked into the samples on the repositories site and I can't
find how to "extract" the data itself from the DOM tree. If you don't mind I
would like to make some simple questions so with your answers I hope I could
start typing code.

//get the DOM representation
DOMNode *doc = parser->getDocument();

I can not find the getDocument method description in the provided
documentation and I am quite confused about it. Anyway, *doc is supposed to
be the DOM representation. So, what I need to do is to extract many elements
(with their childs and attributes) from a XML file, which is supposed to be
represented by *doc once it has been parsed and got. Then, how can I assign,
let's say, the value of the "nickname" element inside its parent element
"user"? getDocument returns the root node? So I guess I can ask it for its
children and then "move" through the tree with methods of the DOMNode API,
like for example, getNodeValue(), getChildNodes() and so on.

Is it ok? Does it exist any other way to extract data from the DOM
representation or this is the one about to use?

Thank you all very much again and sorry for the inconvenience. I am really
interested in using Xerces in the application I am developing, so that's
whay I would like to know how to use it properly.

Cheers,
Javi

**



2007/11/27, David Bertoni <db...@apache.org>:
>
> Sven Bauhan wrote:
> > Hi Javi,
> >
> > the Xerces interface is not really intuitively. A short description can
> be
> > found at the DOM programming giude:
> > http://xerces.apache.org/xerces-c/program.html
> >
> > In the Xerces documentation it is often described to use an extra class
> for
> > the conversion of std::string and XMLChar*. I have written such a class.
> As
> > it is quite short, I attach it here.
> Your class uses XMLString::transcode(), which transcodes to the local code
> page.  This will result in data loss in cases where content contains
> Unicode characters that are not representable in the local code page.  A
> better choice would be to transcode to UTF-8, which is compatible with
> char* APIs, and has the advantage that it can represent any Unicode
> character.
>
> There are many postings in the archives that will illustrate why using
> XMLString::transcode() is a bad idea.  I wish we would actually modify the
> analogous class in our samples so it doesn't do local code page
> transcoding, as it's providing a bad example.
>
> Dave
>

Re: How to parse using DOM

Posted by Javier Gálvez Guerrero <du...@gmail.com>.
Thank you all very much, specially to Sven who shared his own effort.

However, I have looked into the samples on the repositories site and I can't
find how to "extract" the data itself from the DOM tree. If you don't mind I
would like to make some simple questions so with your answers I hope I could
start typing code.

//get the DOM representation
DOMNode *doc = parser->getDocument();

I can not find the getDocument method description in the provided
documentation and I am quite confused about it. Anyway, *doc is supposed to
be the DOM representation. So, what I need to do is to extract many elements
(with their childs and attributes) from a XML file, which is supposed to be
represented by *doc once it has been parsed and got. Then, how can I assign,
let's say, the value of the "nickname" element inside its parent element
"user"? getDocument returns the root node? So I guess I can ask it for its
children and then "move" through the tree with methods of the DOMNode API,
like for example, getNodeValue(), getChildNodes() and so on.

Is it ok? Does it exist any other way to extract data from the DOM
representation or this is the one about to use?

Thank you all very much again and sorry for the inconvenience. I am really
interested in using Xerces in the application I am developing, so that's
whay I would like to know how to use it properly.

Cheers,
Javi

**



2007/11/27, David Bertoni <db...@apache.org>:
>
> Sven Bauhan wrote:
> > Hi Javi,
> >
> > the Xerces interface is not really intuitively. A short description can
> be
> > found at the DOM programming giude:
> > http://xerces.apache.org/xerces-c/program.html
> >
> > In the Xerces documentation it is often described to use an extra class
> for
> > the conversion of std::string and XMLChar*. I have written such a class.
> As
> > it is quite short, I attach it here.
> Your class uses XMLString::transcode(), which transcodes to the local code
> page.  This will result in data loss in cases where content contains
> Unicode characters that are not representable in the local code page.  A
> better choice would be to transcode to UTF-8, which is compatible with
> char* APIs, and has the advantage that it can represent any Unicode
> character.
>
> There are many postings in the archives that will illustrate why using
> XMLString::transcode() is a bad idea.  I wish we would actually modify the
> analogous class in our samples so it doesn't do local code page
> transcoding, as it's providing a bad example.
>
> Dave
>

Re: How to parse using DOM

Posted by David Bertoni <db...@apache.org>.
Sven Bauhan wrote:
>> You are confusing code points and code units.  The size of a code unit in
>> UTF-8 is an octet (8 bits, or one byte on most architectures).  The number
>> of octets required to encode a particular Unicode code point in UTF-8 is 1,
>> 2, 3, or 4.  If you ignore architectures where a byte stores more than 8
>> bits, you can then assume that an octet and a byte are interchangeable.
>>
> Then this means, that std::string can also be used as a container for UTF-8, 
> but its length() does not need to be the correct number of UTF-8 characters.

I'm not sure what you mean by "UTF-8 characters," so I'm going to assume 
you mean the number of Unicode code points. But the system code page might 
also be a multi-byte encoding, or an encoding with shift states, so 
length() is also going to behave the same way in that case -- it's still 
going to tell you the number of code units.

> 
>> UTF-8 was designed to be compatible with the char data type, and
>> null-terminated arrays of UTF-8 code units are compatible with many C/C++
>> runtime functions that accept C-style strings.  The problems start when you
>> rely on locale-specific behavior, or you make assumptions about the
>> relationship of code points and code units.  For example, a substring
>> operation could be problematic if I split a multi-byte UTF-8 sequence.
>> Another example is code that relies on functions like isdigit, which are
>> sensitive to the locale and/or the system default encoding for char.  In
>> that case, UTF-8 bytes might be mistakenly interpreted as code points in
>> the system encoding.
>>
> AFAIK the std::string methods rely on the local code page.

Which member functions are you talking about?  Since "the local code" page 
varies widely depending on the system and the current locale, you need to 
be more specific.

> This means that these methods do not work correctly whith UTF-8. But
> the correctness of the  STL classes and methods is a major advantage
> for the encapsulation. This is  the reason why I think, it would be
> better to convert from XMLChar* to something like std::basic_string<UTF8Char>.
> Then the string methods should  work yet. When using std::string in a
> software you normally use the local  code page anyhow. So this might be
 > also ok when converting from XMLChar*.

There is no way to make std::string work the way you want it to -- it's 
very code unit-oriented.  For example, you might want operator[] to work on 
code points, but there's no way to do that.  You also might want length() 
or size() to tell you the number of code points, but that won't happen 
either.  I've had some experience with these issues when trying to 
implement char_traits<> for UTF-16 code units that works well when there 
are surrogate pairs in the string.

std::string works fine with UTF-8 as long as you restrict yourself to the 
subset of functionality that can be guaranteed to work across all possible 
local code pages and locales.

Dave

Re: How to parse using DOM

Posted by Sven Bauhan <sv...@ast.dfs.de>.
> You are confusing code points and code units.  The size of a code unit in
> UTF-8 is an octet (8 bits, or one byte on most architectures).  The number
> of octets required to encode a particular Unicode code point in UTF-8 is 1,
> 2, 3, or 4.  If you ignore architectures where a byte stores more than 8
> bits, you can then assume that an octet and a byte are interchangeable.
>
Then this means, that std::string can also be used as a container for UTF-8, 
but its length() does not need to be the correct number of UTF-8 characters.

> UTF-8 was designed to be compatible with the char data type, and
> null-terminated arrays of UTF-8 code units are compatible with many C/C++
> runtime functions that accept C-style strings.  The problems start when you
> rely on locale-specific behavior, or you make assumptions about the
> relationship of code points and code units.  For example, a substring
> operation could be problematic if I split a multi-byte UTF-8 sequence.
> Another example is code that relies on functions like isdigit, which are
> sensitive to the locale and/or the system default encoding for char.  In
> that case, UTF-8 bytes might be mistakenly interpreted as code points in
> the system encoding.
>
AFAIK the std::string methods rely on the local code page. This means that 
these methods do not work correctly whith UTF-8. But the correctness of the 
STL classes and methods is a major advantage for the encapsulation. This is 
the reason why I think, it would be better to convert from XMLChar* to 
something like std::basic_string<UTF8Char>. Then the string methods should 
work yet. When using std::string in a software you normally use the local 
code page anyhow. So this might be also ok when converting from XMLChar*.

Sven

Re: How to parse using DOM

Posted by Alberto Massari <am...@datadirect.com>.
Javier Gálvez Guerrero wrote:
> Alberto,
> Thanks again. Everything worked fine.
>
> By the way, as I use getNodeValue and getNodeName to process and assign them
> to my C++ structures I need to parse the XMLCh* returned value to String^
> buy I couldn't find any way to do it. Any idea?
>   
When using Visual Studio 2005, XMLCh* should be just a typedef for 
wchar_t* (and if the binary version doesn't do it already, you can 
change the 'treat wchar_t as a built-in type' option in the Xerces 
project and rebuild it), and you can build String objects from it, directly.

Alberto
> Jesse,
> That's a good question..xD. There are many reasons why I am trying to use
> Xerces in order to parse and create XML files. Maybe you'll find them
> stupid.
>
> Firstly, I am an absolute newbie with C++ as with Xerces (as you have
> already realized). So, I did no research on XML classes offered by the .NET
> framework as I didn't know them.
> Secondly, I am developing an application based on a previous version which
> was developed by another person, who based his app on Xerces to parse XML
> files. The problem is that his design didn't take into account creating or
> writing on XML files, only parsing and reading, so he used the SAX API.
> Then, I had to switch from SAX to DOM and facing all the problems it implies
> (creating a NEW app).
> Thirdly, I thought I could find some help if I based my design on a open
> source solution like Xerces is, and here it is.
>
> Then, if you tell me that it is worth for me working with the System:XML
> files, then I would think about it..haha. But then, what is Xerces for if
> everybody can manage their XML files with these classes?
>
> Cheers,
> Javi
>
> 2007/11/28, Jesse Pelton <js...@pkc.com>:
>   
>> Just out of curiosity, if you're using managed code, why aren't you using
>> the System.XML classes?
>>
>> -----Original Message-----
>> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
>> Sent: Wednesday, November 28, 2007 11:03 AM
>> To: c-users@xerces.apache.org
>> Subject: Re: How to parse using DOM
>>
>> Hi there.
>>
>> Now I can compile the source code file where I have implemented (or tried
>> it...) the DOM parser, some errors have appeared. As they seem quite
>> simple
>> I hope you could help me again:
>>
>> The method in file.cpp is like this (I have followed the guidelines
>> <http://xerces.apache.org/xerces-c/program-dom.html>on Xerces site, except
>> for the exception treatment...):
>>
>> void contents_manager::load_guide(String^ xml_path){
>>
>>     XMLPlatformUtils::Initialize();
>>     XercesDOMParser* parser = new XercesDOMParser();
>>
>>     parser->parse(xml_path);
>>     DOMNode* root = parser->getDocument(); //child_aux1 will be the first
>> child of root
>>     DOMNode* child_aux1, child_aux2, child_aux3, child_aux4, child_aux5,
>> child_aux6, child_aux7; // Compiling errors referring to this line
>>
>>        //...
>>
>> In file.h this is included:
>>
>> #include "../include/gincludes.h"
>> #include "../content/content.h"
>> #include <xercesc/dom/DOM.hpp>
>> #include <xercesc/dom/DOMImplementation.hpp>
>> #include <xercesc/dom/DOMImplementationLS.hpp>
>> #include <xercesc/dom/DOMWriter.hpp>
>> #include <xercesc/util/PlatformUtils.hpp>
>> #include <xercesc/parsers/XercesDOMParser.hpp>
>> #include <xercesc/dom/DOM.hpp>
>> #include <xercesc/util/XMLString.hpp>
>> #include <xercesc/util/PlatformUtils.hpp>
>>
>> using namespace System;
>>
>> XERCES_CPP_NAMESPACE_USE
>>
>> // class definition...
>>
>> Then, when compiling a lot of errors appear saying that it can not be done
>> as I am working with abstracts, referring to the previous red line...
>>
>> 1>.\contents_manager.cpp(17) : error C2259: xercesc_2_8::DOMNode' : no se
>> puede crear una instancia de una clase abstract
>> 1>        debido a los siguientes miembros:
>> 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeName(void) const' :
>> es
>> abstracto
>> 1>        D:\Ser teleco
>>
>> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(246)
>> : vea la declaración de 'xercesc_2_8::DOMNode::getNodeName'
>> 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeValue(void) const' :
>> es
>> abstracto
>> 1>        D:\Ser teleco
>>
>> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(255)
>> : vea la declaración de 'xercesc_2_8::DOMNode::getNodeValue'
>> 1>        'short xercesc_2_8::DOMNode::getNodeType(void) const' : es
>> abstracto
>> ...
>>
>> Any idea of what I need to do regarding this error?
>>
>>
>> By the way, as you may have seen on the arguments of my method, the
>> name/path of the XML file is received with String^ type, so, as I need to
>> have a char* as an argument for parse->parse(file_name), how can I parse
>> it?
>>
>> Thank you very much,
>>
>> Javi
>>
>>
>>
>>
>> 2007/11/28, Sven Bauhan <sv...@ast.dfs.de>:
>>     
>>>> This is not true.  std::string and UTF-8 are fully compatible, as long
>>>>         
>>> as
>>>       
>>>> you make no assumptions about chopping things up at arbitrary indices,
>>>>         
>>> or
>>>       
>>>> the relationship of Unicode code points and UTF-8 code units.  At any
>>>>         
>>> rate,
>>>       
>>>> with a double-byte or multi-byte locale code page, you'd have the same
>>>> issues.
>>>>
>>>>         
>>> I do not really understand what you want to say here. As far as I know
>>> std::string stores strings in single byte units. In UTF-8 the units have
>>> variable length between 1 and 4 bytes. So I cannot see a match here.
>>> I thought to use UTF-8 with the STL you need something like
>>> std::basic_string<UTFChar>.
>>>
>>> Could you tell me, how to transcode the XMLChar* correctly using UTF-8?
>>>
>>> Sven
>>>
>>>       
>
>   


Re: How to parse using DOM

Posted by Javier Gálvez Guerrero <du...@gmail.com>.
The two constructors are declared in content.h:

content(void);
content(string ident);

and defined in content.cpp:

content::content(void){
}

content::content(string ident){
    id = ident;
}

Then, in contents_manager.cpp:

content contents_manager::get_content(string id){
    content c;

    for(int i=0;  i<size; i++){
        c = contents_list.at(i); // contents_list is a vector<content>
        if(c.id == id)
            return c;
    }
    return NULL;
}

The only thing I think can cause this is the line in red, according to what
is said here
<http://msdn2.microsoft.com/en-us/library/c6kkh778%28VS.80%29.aspx>vector.at(i)
returns a reference so, why can't I do this? Compiling there is no error...

I don't know if what is happening has anything to do with Xerces or is only
because my C++ programing "knowledge"...sorry.



2007/11/29, Alberto Massari <am...@datadirect.com>:
>
> Javier Gálvez Guerrero wrote:
> > I have just created my main method. I am creating the "parser" class in
> my
> > project, so this is not the final project yet. I create a class and test
> it
> > with a corresponding main when I have compiled without errors (well,
> with
> > the only one that there is no main). Now there are 8 errors (with the
> main
> > defined).
> >
> > See the quoted text, please.
> >
> > 2007/11/29, Alberto Massari <am...@datadirect.com>:
> >
> >> [...]
> >>> Ventana Resultados
> >>>
> >>> Vinculando...
> >>> contents_manager.obj : warning LNK4248: símbolo (token) de typeref sin
> >>> resolver (01000019) para 'xercesc_2_8.XMLValidator'; no se puede
> >>> ejecutar la imagen
> >>> contents_manager.obj : warning LNK4248: símbolo (token) de typeref sin
> >>> resolver (0100001A) para 'xercesc_2_8.XMLGrammarPool'; no se puede
> >>> ejecutar la imagen
> >>>
> >> I guess you meant writing xercesc_2_8::XMLGrammarPool (i.e. "::"
> instead
> >> of ".")
> >>
> > I have only copied what the Visual C++ 2005 has given as an output when
> > compiling the project. It appears xercesc_2.8.XMLGrammarPool, dot and
> not a
> > colon. Actually, I have not used this on my project. I've only created a
> > parser and worked with the DOMNode API:
> >
> >
> In this case it could be caused by the various "using namespace"
> directives, that under /clr have a different separator. I think the only
> way you have to fix this is by removing the XERCES_CPP_NAMESPACE_USE and
> add a XERCES_CPP_NAMESPACE_QUALIFIER before any Xerces class (like in
> XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::Initialize(); )
> > // contents_manager.cpp
> >
> > #include "../include/gincludes.h"
> > #include "contents_manager.h"
> >
> > //...
> >
> > void contents_manager::load_guide(string xml_path){
> >
> >     XMLPlatformUtils::Initialize();
> >     XercesDOMParser* parser = new XercesDOMParser();
> >
> >     parser->parse(xml_path.c_str());
> >     DOMNode* root = parser->getDocument();
> >     DOMNode* child_aux1, *child_aux2, *child_aux3, *child_aux4,
> *child_aux5,
> > *child_aux6, *child_aux7;
> >
> >     // Check that the XML file defines the content guide
> >     if(XMLString::transcode(root->getNodeName()) == "contents"){
> >
> Beware, this test is wrong; transcode returns a pointer, so you are
> comparing two pointers, and not two strings. Either use strcmp, or
> XMLString::equals, or build two std::string objects. And don't forget to
> call XMLString::release on the pointer returned by transcode, or you'll
> leak memory.
> >         for(child_aux1 = root->getFirstChild(); child_aux1 != NULL;
> > child_aux1 = child_aux1->getNextSibling()){
> >             char* child1_name =
> > XMLString::transcode(child_aux1->getNodeName());
> > //...
> >
> >     delete parser;
> >
> >     XMLPlatformUtils::Terminate();
> > }
> >
> > That is the only I have done in my class regarding Xerces. In the header
> > file I have included these:
> >
> >
> > //contents_manager.h
> >
> > #include "../include/gincludes.h"
> > #include "../content/content.h"
> > #include <xercesc/dom/DOM.hpp>
> > #include <xercesc/dom/DOMImplementation.hpp>
> > #include <xercesc/dom/DOMImplementationLS.hpp>
> > #include <xercesc/dom/DOMWriter.hpp>
> > #include <xercesc/util/PlatformUtils.hpp>
> > #include <xercesc/parsers/XercesDOMParser.hpp>
> > #include <xercesc/dom/DOM.hpp>
> > #include <xercesc/sax/HandlerBase.hpp>
> > #include <xercesc/util/XMLString.hpp>
> > #include <xercesc/util/PlatformUtils.hpp>
> >
> > using namespace System;
> > using namespace System::Runtime::InteropServices;
> > using namespace std;
> >
> > XERCES_CPP_NAMESPACE_USE
> >
> > class contents_manager {
> > //...
> >
> >
> > So that's all.
> >
> Sorry, I extracted the wrong symbol from the spanish description: it
> complains that contents_manager::get_content is using two constructors
> for the "content" class that cannot be
> found,content::content(std::string) and content::content(void). Double
> check if you have implemented them, or just declared in the header file.
>
> Alberto
>

Re: How to parse using DOM

Posted by Alberto Massari <am...@datadirect.com>.
I am running out of ideas; I can suggest you to do:

a) remove all the "using namespace" directive and fully qualify everything
b) add __cdecl to the classes the linker complains about

and in any case I would add copy constructors like content(const 
content& other) to avoid relying on the default behaviour of the compiler.

Alberto

Javier Gálvez Guerrero wrote:
> There are no dlls for my classes, I mean, the only files I have are .h for
> the header, .cpp for the definition of the interface and constructors and
> another cpp for the test of the corresponding class.
>
> So what I have is one folder for "content", where I have content.h and
> content.cpp, and another named contents_manager with has a vector of
> contents and a method for parsing the XML file and fill the vector.
>
> I have another class named user and users_manager and is the same but
> without XML parsing and it works perfectly. I have no copy constructor in
> neither of them...
>
> Sorry if my questions go beyond Xerces. Your help is much appreciated, but
> if you think that's enough you can stop as soon as you want, of course.
>
> Thank you a lot,
> Javi
>
> 2007/11/29, Alberto Massari <am...@datadirect.com>:
>   
>> Javier,
>> these errors are strictly MSVC, Xerces is not involved.
>> Is your "content" class declared in a separate DLL? In this case this
>> page could be right:
>> http://msdn2.microsoft.com/en-us/library/ms235590(vs.80).aspx
>> You should specify __cdecl in the class declaration, as the /clr switch
>> automatically assumes __clrcall.
>>
>> Alberto
>>
>> PS: BTW, does you "contents" class have a copy constructor?
>>
>> Javier Gálvez Guerrero wrote:
>>     
>>> The two constructors are declared in content.h:
>>>
>>> content(void);
>>> content(string ident);
>>>
>>> and defined in content.cpp:
>>>
>>> content::content(void){
>>> }
>>>
>>> content::content(string ident){
>>>     id = ident;
>>> }
>>>
>>> Then, in contents_manager.cpp:
>>>
>>> content contents_manager::get_content(string id){
>>>     content c;
>>>
>>>     for(int i=0;  i<size; i++){
>>>         c = contents_list.at(i); // contents_list is a vector<content>
>>>         if(c.id == id)
>>>             return c;
>>>     }
>>>     return NULL;
>>> }
>>>
>>> The only thing I think can cause this is the line in red, according to
>>>       
>> what
>>     
>>> is said here
>>> <http://msdn2.microsoft.com/en-us/library/c6kkh778%28VS.80%29.aspx>
>>>       
>> vector.at(i)
>>     
>>> returns a reference so, why can't I do this? Compiling there is no
>>>       
>> error...
>>     
>>> I don't know if what is happening has anything to do with Xerces or is
>>>       
>> only
>>     
>>> because my C++ programing "knowledge"...sorry.
>>>
>>> 2007/11/29, Alberto Massari <am...@datadirect.com>:
>>>
>>>       
>>>> Javier Gálvez Guerrero wrote:
>>>>
>>>>         
>>>>> I have just created my main method. I am creating the "parser" class
>>>>>           
>> in
>>     
>>>> my
>>>>
>>>>         
>>>>> project, so this is not the final project yet. I create a class and
>>>>>           
>> test
>>     
>>>> it
>>>>
>>>>         
>>>>> with a corresponding main when I have compiled without errors (well,
>>>>>
>>>>>           
>>>> with
>>>>
>>>>         
>>>>> the only one that there is no main). Now there are 8 errors (with the
>>>>>
>>>>>           
>>>> main
>>>>
>>>>         
>>>>> defined).
>>>>>
>>>>> See the quoted text, please.
>>>>>
>>>>> 2007/11/29, Alberto Massari <am...@datadirect.com>:
>>>>>
>>>>>
>>>>>           
>>>>>> [...]
>>>>>>
>>>>>>             
>>>>>>> Ventana Resultados
>>>>>>>
>>>>>>> Vinculando...
>>>>>>> contents_manager.obj : warning LNK4248: símbolo (token) de typeref
>>>>>>>               
>> sin
>>     
>>>>>>> resolver (01000019) para 'xercesc_2_8.XMLValidator'; no se puede
>>>>>>> ejecutar la imagen
>>>>>>> contents_manager.obj : warning LNK4248: símbolo (token) de typeref
>>>>>>>               
>> sin
>>     
>>>>>>> resolver (0100001A) para 'xercesc_2_8.XMLGrammarPool'; no se puede
>>>>>>> ejecutar la imagen
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>> I guess you meant writing xercesc_2_8::XMLGrammarPool (i.e. "::"
>>>>>>
>>>>>>             
>>>> instead
>>>>
>>>>         
>>>>>> of ".")
>>>>>>
>>>>>>
>>>>>>             
>>>>> I have only copied what the Visual C++ 2005 has given as an output
>>>>>           
>> when
>>     
>>>>> compiling the project. It appears xercesc_2.8.XMLGrammarPool, dot and
>>>>>
>>>>>           
>>>> not a
>>>>
>>>>         
>>>>> colon. Actually, I have not used this on my project. I've only created
>>>>>           
>> a
>>     
>>>>> parser and worked with the DOMNode API:
>>>>>
>>>>>
>>>>>
>>>>>           
>>>> In this case it could be caused by the various "using namespace"
>>>> directives, that under /clr have a different separator. I think the
>>>>         
>> only
>>     
>>>> way you have to fix this is by removing the XERCES_CPP_NAMESPACE_USE
>>>>         
>> and
>>     
>>>> add a XERCES_CPP_NAMESPACE_QUALIFIER before any Xerces class (like in
>>>> XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::Initialize(); )
>>>>
>>>>         
>>>>> // contents_manager.cpp
>>>>>
>>>>> #include "../include/gincludes.h"
>>>>> #include "contents_manager.h"
>>>>>
>>>>> //...
>>>>>
>>>>> void contents_manager::load_guide(string xml_path){
>>>>>
>>>>>     XMLPlatformUtils::Initialize();
>>>>>     XercesDOMParser* parser = new XercesDOMParser();
>>>>>
>>>>>     parser->parse(xml_path.c_str());
>>>>>     DOMNode* root = parser->getDocument();
>>>>>     DOMNode* child_aux1, *child_aux2, *child_aux3, *child_aux4,
>>>>>
>>>>>           
>>>> *child_aux5,
>>>>
>>>>         
>>>>> *child_aux6, *child_aux7;
>>>>>
>>>>>     // Check that the XML file defines the content guide
>>>>>     if(XMLString::transcode(root->getNodeName()) == "contents"){
>>>>>
>>>>>
>>>>>           
>>>> Beware, this test is wrong; transcode returns a pointer, so you are
>>>> comparing two pointers, and not two strings. Either use strcmp, or
>>>> XMLString::equals, or build two std::string objects. And don't forget
>>>>         
>> to
>>     
>>>> call XMLString::release on the pointer returned by transcode, or you'll
>>>> leak memory.
>>>>
>>>>         
>>>>>         for(child_aux1 = root->getFirstChild(); child_aux1 != NULL;
>>>>> child_aux1 = child_aux1->getNextSibling()){
>>>>>             char* child1_name =
>>>>> XMLString::transcode(child_aux1->getNodeName());
>>>>> //...
>>>>>
>>>>>     delete parser;
>>>>>
>>>>>     XMLPlatformUtils::Terminate();
>>>>> }
>>>>>
>>>>> That is the only I have done in my class regarding Xerces. In the
>>>>>           
>> header
>>     
>>>>> file I have included these:
>>>>>
>>>>>
>>>>> //contents_manager.h
>>>>>
>>>>> #include "../include/gincludes.h"
>>>>> #include "../content/content.h"
>>>>> #include <xercesc/dom/DOM.hpp>
>>>>> #include <xercesc/dom/DOMImplementation.hpp>
>>>>> #include <xercesc/dom/DOMImplementationLS.hpp>
>>>>> #include <xercesc/dom/DOMWriter.hpp>
>>>>> #include <xercesc/util/PlatformUtils.hpp>
>>>>> #include <xercesc/parsers/XercesDOMParser.hpp>
>>>>> #include <xercesc/dom/DOM.hpp>
>>>>> #include <xercesc/sax/HandlerBase.hpp>
>>>>> #include <xercesc/util/XMLString.hpp>
>>>>> #include <xercesc/util/PlatformUtils.hpp>
>>>>>
>>>>> using namespace System;
>>>>> using namespace System::Runtime::InteropServices;
>>>>> using namespace std;
>>>>>
>>>>> XERCES_CPP_NAMESPACE_USE
>>>>>
>>>>> class contents_manager {
>>>>> //...
>>>>>
>>>>>
>>>>> So that's all.
>>>>>
>>>>>
>>>>>           
>>>> Sorry, I extracted the wrong symbol from the spanish description: it
>>>> complains that contents_manager::get_content is using two constructors
>>>> for the "content" class that cannot be
>>>> found,content::content(std::string) and content::content(void). Double
>>>> check if you have implemented them, or just declared in the header
>>>>         
>> file.
>>     
>>>> Alberto
>>>>
>>>>
>>>>         
>>>       
>>     
>
>   


Re: How to parse using DOM

Posted by Javier Gálvez Guerrero <du...@gmail.com>.
There are no dlls for my classes, I mean, the only files I have are .h for
the header, .cpp for the definition of the interface and constructors and
another cpp for the test of the corresponding class.

So what I have is one folder for "content", where I have content.h and
content.cpp, and another named contents_manager with has a vector of
contents and a method for parsing the XML file and fill the vector.

I have another class named user and users_manager and is the same but
without XML parsing and it works perfectly. I have no copy constructor in
neither of them...

Sorry if my questions go beyond Xerces. Your help is much appreciated, but
if you think that's enough you can stop as soon as you want, of course.

Thank you a lot,
Javi

2007/11/29, Alberto Massari <am...@datadirect.com>:
>
> Javier,
> these errors are strictly MSVC, Xerces is not involved.
> Is your "content" class declared in a separate DLL? In this case this
> page could be right:
> http://msdn2.microsoft.com/en-us/library/ms235590(vs.80).aspx
> You should specify __cdecl in the class declaration, as the /clr switch
> automatically assumes __clrcall.
>
> Alberto
>
> PS: BTW, does you "contents" class have a copy constructor?
>
> Javier Gálvez Guerrero wrote:
> > The two constructors are declared in content.h:
> >
> > content(void);
> > content(string ident);
> >
> > and defined in content.cpp:
> >
> > content::content(void){
> > }
> >
> > content::content(string ident){
> >     id = ident;
> > }
> >
> > Then, in contents_manager.cpp:
> >
> > content contents_manager::get_content(string id){
> >     content c;
> >
> >     for(int i=0;  i<size; i++){
> >         c = contents_list.at(i); // contents_list is a vector<content>
> >         if(c.id == id)
> >             return c;
> >     }
> >     return NULL;
> > }
> >
> > The only thing I think can cause this is the line in red, according to
> what
> > is said here
> > <http://msdn2.microsoft.com/en-us/library/c6kkh778%28VS.80%29.aspx>
> vector.at(i)
> > returns a reference so, why can't I do this? Compiling there is no
> error...
> >
> > I don't know if what is happening has anything to do with Xerces or is
> only
> > because my C++ programing "knowledge"...sorry.
> >
> > 2007/11/29, Alberto Massari <am...@datadirect.com>:
> >
> >> Javier Gálvez Guerrero wrote:
> >>
> >>> I have just created my main method. I am creating the "parser" class
> in
> >>>
> >> my
> >>
> >>> project, so this is not the final project yet. I create a class and
> test
> >>>
> >> it
> >>
> >>> with a corresponding main when I have compiled without errors (well,
> >>>
> >> with
> >>
> >>> the only one that there is no main). Now there are 8 errors (with the
> >>>
> >> main
> >>
> >>> defined).
> >>>
> >>> See the quoted text, please.
> >>>
> >>> 2007/11/29, Alberto Massari <am...@datadirect.com>:
> >>>
> >>>
> >>>> [...]
> >>>>
> >>>>> Ventana Resultados
> >>>>>
> >>>>> Vinculando...
> >>>>> contents_manager.obj : warning LNK4248: símbolo (token) de typeref
> sin
> >>>>> resolver (01000019) para 'xercesc_2_8.XMLValidator'; no se puede
> >>>>> ejecutar la imagen
> >>>>> contents_manager.obj : warning LNK4248: símbolo (token) de typeref
> sin
> >>>>> resolver (0100001A) para 'xercesc_2_8.XMLGrammarPool'; no se puede
> >>>>> ejecutar la imagen
> >>>>>
> >>>>>
> >>>> I guess you meant writing xercesc_2_8::XMLGrammarPool (i.e. "::"
> >>>>
> >> instead
> >>
> >>>> of ".")
> >>>>
> >>>>
> >>> I have only copied what the Visual C++ 2005 has given as an output
> when
> >>> compiling the project. It appears xercesc_2.8.XMLGrammarPool, dot and
> >>>
> >> not a
> >>
> >>> colon. Actually, I have not used this on my project. I've only created
> a
> >>> parser and worked with the DOMNode API:
> >>>
> >>>
> >>>
> >> In this case it could be caused by the various "using namespace"
> >> directives, that under /clr have a different separator. I think the
> only
> >> way you have to fix this is by removing the XERCES_CPP_NAMESPACE_USE
> and
> >> add a XERCES_CPP_NAMESPACE_QUALIFIER before any Xerces class (like in
> >> XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::Initialize(); )
> >>
> >>> // contents_manager.cpp
> >>>
> >>> #include "../include/gincludes.h"
> >>> #include "contents_manager.h"
> >>>
> >>> //...
> >>>
> >>> void contents_manager::load_guide(string xml_path){
> >>>
> >>>     XMLPlatformUtils::Initialize();
> >>>     XercesDOMParser* parser = new XercesDOMParser();
> >>>
> >>>     parser->parse(xml_path.c_str());
> >>>     DOMNode* root = parser->getDocument();
> >>>     DOMNode* child_aux1, *child_aux2, *child_aux3, *child_aux4,
> >>>
> >> *child_aux5,
> >>
> >>> *child_aux6, *child_aux7;
> >>>
> >>>     // Check that the XML file defines the content guide
> >>>     if(XMLString::transcode(root->getNodeName()) == "contents"){
> >>>
> >>>
> >> Beware, this test is wrong; transcode returns a pointer, so you are
> >> comparing two pointers, and not two strings. Either use strcmp, or
> >> XMLString::equals, or build two std::string objects. And don't forget
> to
> >> call XMLString::release on the pointer returned by transcode, or you'll
> >> leak memory.
> >>
> >>>         for(child_aux1 = root->getFirstChild(); child_aux1 != NULL;
> >>> child_aux1 = child_aux1->getNextSibling()){
> >>>             char* child1_name =
> >>> XMLString::transcode(child_aux1->getNodeName());
> >>> //...
> >>>
> >>>     delete parser;
> >>>
> >>>     XMLPlatformUtils::Terminate();
> >>> }
> >>>
> >>> That is the only I have done in my class regarding Xerces. In the
> header
> >>> file I have included these:
> >>>
> >>>
> >>> //contents_manager.h
> >>>
> >>> #include "../include/gincludes.h"
> >>> #include "../content/content.h"
> >>> #include <xercesc/dom/DOM.hpp>
> >>> #include <xercesc/dom/DOMImplementation.hpp>
> >>> #include <xercesc/dom/DOMImplementationLS.hpp>
> >>> #include <xercesc/dom/DOMWriter.hpp>
> >>> #include <xercesc/util/PlatformUtils.hpp>
> >>> #include <xercesc/parsers/XercesDOMParser.hpp>
> >>> #include <xercesc/dom/DOM.hpp>
> >>> #include <xercesc/sax/HandlerBase.hpp>
> >>> #include <xercesc/util/XMLString.hpp>
> >>> #include <xercesc/util/PlatformUtils.hpp>
> >>>
> >>> using namespace System;
> >>> using namespace System::Runtime::InteropServices;
> >>> using namespace std;
> >>>
> >>> XERCES_CPP_NAMESPACE_USE
> >>>
> >>> class contents_manager {
> >>> //...
> >>>
> >>>
> >>> So that's all.
> >>>
> >>>
> >> Sorry, I extracted the wrong symbol from the spanish description: it
> >> complains that contents_manager::get_content is using two constructors
> >> for the "content" class that cannot be
> >> found,content::content(std::string) and content::content(void). Double
> >> check if you have implemented them, or just declared in the header
> file.
> >>
> >> Alberto
> >>
> >>
> >
> >
>
>

Re: How to parse using DOM

Posted by Alberto Massari <am...@datadirect.com>.
Javier,
these errors are strictly MSVC, Xerces is not involved.
Is your "content" class declared in a separate DLL? In this case this 
page could be right: 
http://msdn2.microsoft.com/en-us/library/ms235590(vs.80).aspx
You should specify __cdecl in the class declaration, as the /clr switch 
automatically assumes __clrcall.

Alberto

PS: BTW, does you "contents" class have a copy constructor?

Javier Gálvez Guerrero wrote:
> The two constructors are declared in content.h:
>
> content(void);
> content(string ident);
>
> and defined in content.cpp:
>
> content::content(void){
> }
>
> content::content(string ident){
>     id = ident;
> }
>
> Then, in contents_manager.cpp:
>
> content contents_manager::get_content(string id){
>     content c;
>
>     for(int i=0;  i<size; i++){
>         c = contents_list.at(i); // contents_list is a vector<content>
>         if(c.id == id)
>             return c;
>     }
>     return NULL;
> }
>
> The only thing I think can cause this is the line in red, according to what
> is said here
> <http://msdn2.microsoft.com/en-us/library/c6kkh778%28VS.80%29.aspx>vector.at(i)
> returns a reference so, why can't I do this? Compiling there is no error...
>
> I don't know if what is happening has anything to do with Xerces or is only
> because my C++ programing "knowledge"...sorry.
>
> 2007/11/29, Alberto Massari <am...@datadirect.com>:
>   
>> Javier Gálvez Guerrero wrote:
>>     
>>> I have just created my main method. I am creating the "parser" class in
>>>       
>> my
>>     
>>> project, so this is not the final project yet. I create a class and test
>>>       
>> it
>>     
>>> with a corresponding main when I have compiled without errors (well,
>>>       
>> with
>>     
>>> the only one that there is no main). Now there are 8 errors (with the
>>>       
>> main
>>     
>>> defined).
>>>
>>> See the quoted text, please.
>>>
>>> 2007/11/29, Alberto Massari <am...@datadirect.com>:
>>>
>>>       
>>>> [...]
>>>>         
>>>>> Ventana Resultados
>>>>>
>>>>> Vinculando...
>>>>> contents_manager.obj : warning LNK4248: símbolo (token) de typeref sin
>>>>> resolver (01000019) para 'xercesc_2_8.XMLValidator'; no se puede
>>>>> ejecutar la imagen
>>>>> contents_manager.obj : warning LNK4248: símbolo (token) de typeref sin
>>>>> resolver (0100001A) para 'xercesc_2_8.XMLGrammarPool'; no se puede
>>>>> ejecutar la imagen
>>>>>
>>>>>           
>>>> I guess you meant writing xercesc_2_8::XMLGrammarPool (i.e. "::"
>>>>         
>> instead
>>     
>>>> of ".")
>>>>
>>>>         
>>> I have only copied what the Visual C++ 2005 has given as an output when
>>> compiling the project. It appears xercesc_2.8.XMLGrammarPool, dot and
>>>       
>> not a
>>     
>>> colon. Actually, I have not used this on my project. I've only created a
>>> parser and worked with the DOMNode API:
>>>
>>>
>>>       
>> In this case it could be caused by the various "using namespace"
>> directives, that under /clr have a different separator. I think the only
>> way you have to fix this is by removing the XERCES_CPP_NAMESPACE_USE and
>> add a XERCES_CPP_NAMESPACE_QUALIFIER before any Xerces class (like in
>> XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::Initialize(); )
>>     
>>> // contents_manager.cpp
>>>
>>> #include "../include/gincludes.h"
>>> #include "contents_manager.h"
>>>
>>> //...
>>>
>>> void contents_manager::load_guide(string xml_path){
>>>
>>>     XMLPlatformUtils::Initialize();
>>>     XercesDOMParser* parser = new XercesDOMParser();
>>>
>>>     parser->parse(xml_path.c_str());
>>>     DOMNode* root = parser->getDocument();
>>>     DOMNode* child_aux1, *child_aux2, *child_aux3, *child_aux4,
>>>       
>> *child_aux5,
>>     
>>> *child_aux6, *child_aux7;
>>>
>>>     // Check that the XML file defines the content guide
>>>     if(XMLString::transcode(root->getNodeName()) == "contents"){
>>>
>>>       
>> Beware, this test is wrong; transcode returns a pointer, so you are
>> comparing two pointers, and not two strings. Either use strcmp, or
>> XMLString::equals, or build two std::string objects. And don't forget to
>> call XMLString::release on the pointer returned by transcode, or you'll
>> leak memory.
>>     
>>>         for(child_aux1 = root->getFirstChild(); child_aux1 != NULL;
>>> child_aux1 = child_aux1->getNextSibling()){
>>>             char* child1_name =
>>> XMLString::transcode(child_aux1->getNodeName());
>>> //...
>>>
>>>     delete parser;
>>>
>>>     XMLPlatformUtils::Terminate();
>>> }
>>>
>>> That is the only I have done in my class regarding Xerces. In the header
>>> file I have included these:
>>>
>>>
>>> //contents_manager.h
>>>
>>> #include "../include/gincludes.h"
>>> #include "../content/content.h"
>>> #include <xercesc/dom/DOM.hpp>
>>> #include <xercesc/dom/DOMImplementation.hpp>
>>> #include <xercesc/dom/DOMImplementationLS.hpp>
>>> #include <xercesc/dom/DOMWriter.hpp>
>>> #include <xercesc/util/PlatformUtils.hpp>
>>> #include <xercesc/parsers/XercesDOMParser.hpp>
>>> #include <xercesc/dom/DOM.hpp>
>>> #include <xercesc/sax/HandlerBase.hpp>
>>> #include <xercesc/util/XMLString.hpp>
>>> #include <xercesc/util/PlatformUtils.hpp>
>>>
>>> using namespace System;
>>> using namespace System::Runtime::InteropServices;
>>> using namespace std;
>>>
>>> XERCES_CPP_NAMESPACE_USE
>>>
>>> class contents_manager {
>>> //...
>>>
>>>
>>> So that's all.
>>>
>>>       
>> Sorry, I extracted the wrong symbol from the spanish description: it
>> complains that contents_manager::get_content is using two constructors
>> for the "content" class that cannot be
>> found,content::content(std::string) and content::content(void). Double
>> check if you have implemented them, or just declared in the header file.
>>
>> Alberto
>>
>>     
>
>   


Re: How to parse using DOM

Posted by Javier Gálvez Guerrero <du...@gmail.com>.
The two constructors are declared in content.h:

content(void);
content(string ident);

and defined in content.cpp:

content::content(void){
}

content::content(string ident){
    id = ident;
}

Then, in contents_manager.cpp:

content contents_manager::get_content(string id){
    content c;

    for(int i=0;  i<size; i++){
        c = contents_list.at(i); // contents_list is a vector<content>
        if(c.id == id)
            return c;
    }
    return NULL;
}

The only thing I think can cause this is the line in red, according to what
is said here
<http://msdn2.microsoft.com/en-us/library/c6kkh778%28VS.80%29.aspx>vector.at(i)
returns a reference so, why can't I do this? Compiling there is no error...

I don't know if what is happening has anything to do with Xerces or is only
because my C++ programing "knowledge"...sorry.

2007/11/29, Alberto Massari <am...@datadirect.com>:
>
> Javier Gálvez Guerrero wrote:
> > I have just created my main method. I am creating the "parser" class in
> my
> > project, so this is not the final project yet. I create a class and test
> it
> > with a corresponding main when I have compiled without errors (well,
> with
> > the only one that there is no main). Now there are 8 errors (with the
> main
> > defined).
> >
> > See the quoted text, please.
> >
> > 2007/11/29, Alberto Massari <am...@datadirect.com>:
> >
> >> [...]
> >>> Ventana Resultados
> >>>
> >>> Vinculando...
> >>> contents_manager.obj : warning LNK4248: símbolo (token) de typeref sin
> >>> resolver (01000019) para 'xercesc_2_8.XMLValidator'; no se puede
> >>> ejecutar la imagen
> >>> contents_manager.obj : warning LNK4248: símbolo (token) de typeref sin
> >>> resolver (0100001A) para 'xercesc_2_8.XMLGrammarPool'; no se puede
> >>> ejecutar la imagen
> >>>
> >> I guess you meant writing xercesc_2_8::XMLGrammarPool (i.e. "::"
> instead
> >> of ".")
> >>
> > I have only copied what the Visual C++ 2005 has given as an output when
> > compiling the project. It appears xercesc_2.8.XMLGrammarPool, dot and
> not a
> > colon. Actually, I have not used this on my project. I've only created a
> > parser and worked with the DOMNode API:
> >
> >
> In this case it could be caused by the various "using namespace"
> directives, that under /clr have a different separator. I think the only
> way you have to fix this is by removing the XERCES_CPP_NAMESPACE_USE and
> add a XERCES_CPP_NAMESPACE_QUALIFIER before any Xerces class (like in
> XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::Initialize(); )
> > // contents_manager.cpp
> >
> > #include "../include/gincludes.h"
> > #include "contents_manager.h"
> >
> > //...
> >
> > void contents_manager::load_guide(string xml_path){
> >
> >     XMLPlatformUtils::Initialize();
> >     XercesDOMParser* parser = new XercesDOMParser();
> >
> >     parser->parse(xml_path.c_str());
> >     DOMNode* root = parser->getDocument();
> >     DOMNode* child_aux1, *child_aux2, *child_aux3, *child_aux4,
> *child_aux5,
> > *child_aux6, *child_aux7;
> >
> >     // Check that the XML file defines the content guide
> >     if(XMLString::transcode(root->getNodeName()) == "contents"){
> >
> Beware, this test is wrong; transcode returns a pointer, so you are
> comparing two pointers, and not two strings. Either use strcmp, or
> XMLString::equals, or build two std::string objects. And don't forget to
> call XMLString::release on the pointer returned by transcode, or you'll
> leak memory.
> >         for(child_aux1 = root->getFirstChild(); child_aux1 != NULL;
> > child_aux1 = child_aux1->getNextSibling()){
> >             char* child1_name =
> > XMLString::transcode(child_aux1->getNodeName());
> > //...
> >
> >     delete parser;
> >
> >     XMLPlatformUtils::Terminate();
> > }
> >
> > That is the only I have done in my class regarding Xerces. In the header
> > file I have included these:
> >
> >
> > //contents_manager.h
> >
> > #include "../include/gincludes.h"
> > #include "../content/content.h"
> > #include <xercesc/dom/DOM.hpp>
> > #include <xercesc/dom/DOMImplementation.hpp>
> > #include <xercesc/dom/DOMImplementationLS.hpp>
> > #include <xercesc/dom/DOMWriter.hpp>
> > #include <xercesc/util/PlatformUtils.hpp>
> > #include <xercesc/parsers/XercesDOMParser.hpp>
> > #include <xercesc/dom/DOM.hpp>
> > #include <xercesc/sax/HandlerBase.hpp>
> > #include <xercesc/util/XMLString.hpp>
> > #include <xercesc/util/PlatformUtils.hpp>
> >
> > using namespace System;
> > using namespace System::Runtime::InteropServices;
> > using namespace std;
> >
> > XERCES_CPP_NAMESPACE_USE
> >
> > class contents_manager {
> > //...
> >
> >
> > So that's all.
> >
> Sorry, I extracted the wrong symbol from the spanish description: it
> complains that contents_manager::get_content is using two constructors
> for the "content" class that cannot be
> found,content::content(std::string) and content::content(void). Double
> check if you have implemented them, or just declared in the header file.
>
> Alberto
>

Re: How to parse using DOM

Posted by Alberto Massari <am...@datadirect.com>.
Javier Gálvez Guerrero wrote:
> I have just created my main method. I am creating the "parser" class in my
> project, so this is not the final project yet. I create a class and test it
> with a corresponding main when I have compiled without errors (well, with
> the only one that there is no main). Now there are 8 errors (with the main
> defined).
>
> See the quoted text, please.
>
> 2007/11/29, Alberto Massari <am...@datadirect.com>:
>   
>> [...]
>>> Ventana Resultados
>>>
>>> Vinculando...
>>> contents_manager.obj : warning LNK4248: símbolo (token) de typeref sin
>>> resolver (01000019) para 'xercesc_2_8.XMLValidator'; no se puede
>>> ejecutar la imagen
>>> contents_manager.obj : warning LNK4248: símbolo (token) de typeref sin
>>> resolver (0100001A) para 'xercesc_2_8.XMLGrammarPool'; no se puede
>>> ejecutar la imagen
>>>       
>> I guess you meant writing xercesc_2_8::XMLGrammarPool (i.e. "::" instead
>> of ".")
>>     
> I have only copied what the Visual C++ 2005 has given as an output when
> compiling the project. It appears xercesc_2.8.XMLGrammarPool, dot and not a
> colon. Actually, I have not used this on my project. I've only created a
> parser and worked with the DOMNode API:
>
>   
In this case it could be caused by the various "using namespace" 
directives, that under /clr have a different separator. I think the only 
way you have to fix this is by removing the XERCES_CPP_NAMESPACE_USE and 
add a XERCES_CPP_NAMESPACE_QUALIFIER before any Xerces class (like in 
XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::Initialize(); )
> // contents_manager.cpp
>
> #include "../include/gincludes.h"
> #include "contents_manager.h"
>
> //...
>
> void contents_manager::load_guide(string xml_path){
>
>     XMLPlatformUtils::Initialize();
>     XercesDOMParser* parser = new XercesDOMParser();
>
>     parser->parse(xml_path.c_str());
>     DOMNode* root = parser->getDocument();
>     DOMNode* child_aux1, *child_aux2, *child_aux3, *child_aux4, *child_aux5,
> *child_aux6, *child_aux7;
>
>     // Check that the XML file defines the content guide
>     if(XMLString::transcode(root->getNodeName()) == "contents"){
>   
Beware, this test is wrong; transcode returns a pointer, so you are 
comparing two pointers, and not two strings. Either use strcmp, or 
XMLString::equals, or build two std::string objects. And don't forget to 
call XMLString::release on the pointer returned by transcode, or you'll 
leak memory.
>         for(child_aux1 = root->getFirstChild(); child_aux1 != NULL;
> child_aux1 = child_aux1->getNextSibling()){
>             char* child1_name =
> XMLString::transcode(child_aux1->getNodeName());
> //...
>
>     delete parser;
>
>     XMLPlatformUtils::Terminate();
> }
>
> That is the only I have done in my class regarding Xerces. In the header
> file I have included these:
>
>
> //contents_manager.h
>
> #include "../include/gincludes.h"
> #include "../content/content.h"
> #include <xercesc/dom/DOM.hpp>
> #include <xercesc/dom/DOMImplementation.hpp>
> #include <xercesc/dom/DOMImplementationLS.hpp>
> #include <xercesc/dom/DOMWriter.hpp>
> #include <xercesc/util/PlatformUtils.hpp>
> #include <xercesc/parsers/XercesDOMParser.hpp>
> #include <xercesc/dom/DOM.hpp>
> #include <xercesc/sax/HandlerBase.hpp>
> #include <xercesc/util/XMLString.hpp>
> #include <xercesc/util/PlatformUtils.hpp>
>
> using namespace System;
> using namespace System::Runtime::InteropServices;
> using namespace std;
>
> XERCES_CPP_NAMESPACE_USE
>
> class contents_manager {
> //...
>
>
> So that's all.
>   
Sorry, I extracted the wrong symbol from the spanish description: it 
complains that contents_manager::get_content is using two constructors 
for the "content" class that cannot be 
found,content::content(std::string) and content::content(void). Double 
check if you have implemented them, or just declared in the header file.

Alberto

Re: How to parse using DOM

Posted by Javier Gálvez Guerrero <du...@gmail.com>.
I have just created my main method. I am creating the "parser" class in my
project, so this is not the final project yet. I create a class and test it
with a corresponding main when I have compiled without errors (well, with
the only one that there is no main). Now there are 8 errors (with the main
defined).

See the quoted text, please.

2007/11/29, Alberto Massari <am...@datadirect.com>:
>
> Javier Gálvez Guerrero wrote:
> > Sorry, I didn't find the "additional libraries" but now these to lib's
> are
> > added. However, now appear 10 errors...(before, they were 74).
> >
> > Creando archivo temporal "d:\Ser teleco
> > mola\IPTV\Aplicación\Desarrollo\dIPTV\contents_manager\Debug
> \RSP00000716012284764.rsp"
> > con contenido
> > [
> > /OUT:"D:\Ser teleco
> > mola\IPTV\Aplicación\Desarrollo\dIPTV\Debug\contents_manager.exe"
> > /INCREMENTAL /LIBPATH:"D:\Ser teleco
> > mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\lib" /MANIFEST
> > /MANIFESTFILE:"Debug\contents_manager.exe.intermediate.manifest"
> > /DEBUG /ASSEMBLYDEBUG /PDB:"d:\Ser teleco
> > mola\IPTV\Aplicación\Desarrollo\dIPTV\debug\contents_manager.pdb"
> > /SUBSYSTEM:CONSOLE /MACHINE:X86 /FIXED:No xerces-c_2.lib
> > xerces-c_2D.lib kernel32.lib
> >
> > ".\Debug\contents_manager.obj"
> > ]
> > Creando línea de comandos "link.exe @"d:\Ser teleco
> > mola\IPTV\Aplicación\Desarrollo\dIPTV\contents_manager\Debug
> \RSP00000716012284764.rsp"
> > /NOLOGO /ERRORREPORT:PROMPT"
> >
> > Ventana Resultados
> >
> > Vinculando...
> > contents_manager.obj : warning LNK4248: símbolo (token) de typeref sin
> > resolver (01000019) para 'xercesc_2_8.XMLValidator'; no se puede
> > ejecutar la imagen
> > contents_manager.obj : warning LNK4248: símbolo (token) de typeref sin
> > resolver (0100001A) para 'xercesc_2_8.XMLGrammarPool'; no se puede
> > ejecutar la imagen
> >
> I guess you meant writing xercesc_2_8::XMLGrammarPool (i.e. "::" instead
> of ".")



I have only copied what the Visual C++ 2005 has given as an output when
compiling the project. It appears xercesc_2.8.XMLGrammarPool, dot and not a
colon. Actually, I have not used this on my project. I've only created a
parser and worked with the DOMNode API:

// contents_manager.cpp

#include "../include/gincludes.h"
#include "contents_manager.h"

//...

void contents_manager::load_guide(string xml_path){

    XMLPlatformUtils::Initialize();
    XercesDOMParser* parser = new XercesDOMParser();

    parser->parse(xml_path.c_str());
    DOMNode* root = parser->getDocument();
    DOMNode* child_aux1, *child_aux2, *child_aux3, *child_aux4, *child_aux5,
*child_aux6, *child_aux7;

    // Check that the XML file defines the content guide
    if(XMLString::transcode(root->getNodeName()) == "contents"){

        for(child_aux1 = root->getFirstChild(); child_aux1 != NULL;
child_aux1 = child_aux1->getNextSibling()){
            char* child1_name =
XMLString::transcode(child_aux1->getNodeName());
//...

    delete parser;

    XMLPlatformUtils::Terminate();
}

That is the only I have done in my class regarding Xerces. In the header
file I have included these:


//contents_manager.h

#include "../include/gincludes.h"
#include "../content/content.h"
#include <xercesc/dom/DOM.hpp>
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMImplementationLS.hpp>
#include <xercesc/dom/DOMWriter.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/sax/HandlerBase.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>

using namespace System;
using namespace System::Runtime::InteropServices;
using namespace std;

XERCES_CPP_NAMESPACE_USE

class contents_manager {
//...


So that's all.

> contents_manager.obj : error LNK2028: se hace referencia al símbolo
> > (token) sin resolver (0A00043C) "public: __thiscall
> > content::content(class std::basic_string,class std::allocator >)"
> > (??0content@@$$FQAE@V?$basic_string@DU?$char_traits@D@std@@
> V?$allocator@D@2@@std@@@Z)
> > en la función "public: class content __thiscall
> > contents_manager::get_content(class std::basic_string,class
> > std::allocator >)"
> > (?get_content@contents_manager@@$$FQAE?AVcontent@@V?$basic_string@DU
> ?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
> > contents_manager.obj : error LNK2028: se hace referencia al símbolo
> > (token) sin resolver (0A00043D) "public: __thiscall
> > content::content(void)" (??0content@@$$FQAE@XZ) en la función "public:
> > class content __thiscall contents_manager::get_content(class
> > std::basic_string,class std::allocator >)"
> > (?get_content@contents_manager@@$$FQAE?AVcontent@@V?$basic_string@DU
> ?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
> > ...
> >
> You are including a library that exposes a contents_manager class, but
> you didn't add the corresponding LIB file in the 'additional libraries'
> (you should know the name of the library, contents_manager is not part
> of Xerces)



What do you mean? The only libs I am using are these from Xerces.
Contents_manager is the class I've just created with nothing strange at all
(or this is what I think...).

> MSVCRTD.lib(crtexe.obj) : error LNK2019: símbolo externo _main sin
> > resolver al que se hace referencia en la función ___tmainCRTStartup
> > D:\Ser teleco mola\IPTV\Aplicación\Desarroll
> o\dIPTV\Debug\contents_manager.exe
> >
> Have you written a main() method?
>
> Alberto
> > : fatal error LNK1120: 9 externos sin resolver
> >
> >
> > Should I declare anything like an extern????
> >
> > Javi
> >
> >
> > 2007/11/29, Javier Gálvez Guerrero <du...@gmail.com>:
> >
> >> I have added the two lib paths in Tools | Options | Project Solutions |
> >> VC++ Directories (selecting Library files) and Project | Properities |
> >> Linker | General | Additional library folders (Selecting the "All
> >> configurations" on Configuration combo on top left.
> >>
> >> And in the BuildLog.htm file appears this:
> >>
> >>
> >> Creando archivo temporal "d:\Ser teleco
> mola\IPTV\Aplicación\Desarrollo\dIPTV\contents_manager\Debug\RSP00000416012186844.rsp"
> con contenido
> >>
> >> [
> >> /OUT:"D:\Ser teleco
> mola\IPTV\Aplicación\Desarrollo\dIPTV\Debug\contents_manager.exe"
> /INCREMENTAL /LIBPATH:"D:\Ser teleco
> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\lib"
> >>  /MANIFEST
> /MANIFESTFILE:"Debug\contents_manager.exe.intermediate.manifest" /DEBUG
> /ASSEMBLYDEBUG /PDB:"d:\Ser teleco
> mola\IPTV\Aplicación\Desarrollo\dIPTV\debug\contents_manager.pdb"
> /SUBSYSTEM:CONSOLE /MACHINE:X86 /FIXED:No
> >> kernel32.lib
> >>
> >> ".\Debug\contents_manager.obj"
> >> ]
> >> Creando línea de comandos "link.exe @"d:\Ser teleco
> mola\IPTV\Aplicación\Desarrollo\dIPTV\contents_manager\Debug\RSP00000416012186844.rsp"
> /NOLOGO /ERRORREPORT:PROMPT"
> >>
> >>
> >>
> >> So it seems I have added properly the folder but it does not work. This
> >> folder contains xerces_c_2.lib, xerces_c_2D.lib and static(2) and
> depdom (4)
> >> extensions, 8 files.
> >>
> >> I don't know if I need to configure anything more... I am so sorry, but
> >> can you help me, please? I promise you that as soon as I can link
> properly I
> >> will ask more "interesting" questions..haha.
> >>
> >> Thank you a lot,
> >> Javi
> >>
> >>
> >> 2007/11/29, Alberto Massari <am...@datadirect.com>:
> >>
> >>> Javier,
> >>> the same operation you did for the include folder should be done for
> the
> >>> lib folder (using the Link property page of the Project properties if
> >>> you want to fix just this project, or using the VC++ Directories
> >>> property page in the Tools | Options menu, after selecting Library
> files
> >>> in the combo box).
> >>> In case you didn't already do it, you also need to list xerces_2.lib
> >>> (for release builds) and xerces_2D.lib (for debug builds) in the
> >>> 'additional libraries' entry of the project properties.
> >>>
> >>> Alberto
> >>>
> >>> Javier Gálvez Guerrero wrote:
> >>>
> >>>> I think that the attachement doesn't work properly, so I'll copy
> paste
> >>>>
> >>> the
> >>>
> >>>> first outputs:
> >>>>
> >>>> Vinculando... contents_manager.obj : warning LNK4248: símbolo (token)
> >>>>
> >>> de
> >>>
> >>>> typeref sin resolver (01000019) para 'xercesc_2_8.XMLValidator'; no
> se
> >>>>
> >>> puede
> >>>
> >>>> ejecutar la imagen contents_manager.obj: warning LNK4248: símbolo
> >>>>
> >>> (token) de
> >>>
> >>>> typeref sin resolver (0100001A) para 'xercesc_2_8.XMLGrammarPool'; no
> >>>>
> >>> se
> >>>
> >>>> puede ejecutar la imagen contents_manager.obj : error LNK2028: se
> hace
> >>>> referencia al símbolo (token) sin resolver (0A0003AE) "public: class
> >>>> xercesc_2_8::DOMDocument * __thiscall
> >>>> xercesc_2_8::AbstractDOMParser::getDocument(void)" (?getDocument@
> >>>> AbstractDOMParser@xercesc_2_8@@$$FQAEPAVDOMDocument@2@XZ) en la
> >>>>
> >>> función
> >>>
> >>>> "public: void __thiscall contents_manager::load_guide(class
> >>>> std::basic_string,class std::allocator >)"
> >>>> (?load_guide@contents_manager@@$$FQAEXV?$basic_string@
> >>>>
> >>> DU?$char_traits@D
> >>>
> >>>> @std@@V?$allocator@D@2@@std@@@Z)
> >>>>
> >>>> Sorry for the inconvenience,
> >>>> Javi
> >>>>
> >>>> 2007/11/28, Javier Gálvez Guerrero <du...@gmail.com>:
> >>>>
> >>>>
> >>>>> Should I configure anything for the linking files as I did with the
> >>>>> Include?
> >>>>>
> >>>>> I have compiled my code with no errors, but at the time of linking
> >>>>>
> >>> appear
> >>>
> >>>>> lots of errors (BuildLog.htm attached).
> >>>>>
> >>>>> Thank you,
> >>>>> Javi
> >>>>>
> >>>>> PS: Jesse, thanks a lot for your explanation about System.XML and
> its
> >>>>> features. I am trying to design an application as multiplatform as
> >>>>>
> >>> possible
> >>>
> >>>>> and now that I have started with Xerces I would like to use it. But
> >>>>>
> >>> it's
> >>>
> >>>>> good to know all the alternatives out there. =).
> >>>>>
> >>>>>
> >>>>>
> >>>>> 2007/11/28, Jesse Pelton <js...@pkc.com>:
> >>>>>
> >>>>>
> >>>>>> Regarding System.XML versus Xerces: Xerces exists to provide a
> >>>>>>
> >>> solid,
> >>>
> >>>>>> open-source, cross-platform implementation of certain XML standards
> >>>>>>
> >>> for C++
> >>>
> >>>>>> developers.  Almost all C++ developers are using unmanaged code; I
> >>>>>>
> >>> think
> >>>
> >>>>>> you're the first I've heard of using Xerces with managed C++.
> >>>>>>
> >>>>>> To the extent that you're in a managed-code environment, Mono's
> >>>>>> implementation of System.XML may fulfill the same requirements.  If
> >>>>>> you're targeting Windows exclusively, the cross-platform issue is
> of
> >>>>>>
> >>> no
> >>>
> >>>>>> consequence; you'll use the Microsoft implementation.  My
> >>>>>>
> >>> understanding is
> >>>
> >>>>>> that System.XML is well-designed and robust, but I can't vouch for
> >>>>>>
> >>> that
> >>>
> >>>>>> myself.  That leaves openness; if that's not important for your
> >>>>>>
> >>> project,
> >>>
> >>>>>> System.XML would probably be at least as good a fit as Xerces (and
> I
> >>>>>>
> >>>>>> imagine there's a large community of managed code developers who
> can
> >>>>>>
> >>> help
> >>>
> >>>>>> you out, though not one of them is as good as Alberto).  Using
> >>>>>> System.XML would avoid redundancy: you wouldn't have to distribute,
> >>>>>>
> >>> and
> >>>
> >>>>>> your developers wouldn't have to understand, an additional library.
> >>>>>>
> >>>>>> This is not to say that you shouldn't use Xerces; it's a great
> >>>>>> library.  Just know your options.
> >>>>>>
> >>>>>> -----Original Message-----
> >>>>>> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
> >>>>>> Sent: Wednesday, November 28, 2007 12:15 PM
> >>>>>> To: c-users@xerces.apache.org
> >>>>>> Subject: Re: How to parse using DOM
> >>>>>>
> >>>>>> Alberto,
> >>>>>> Thanks again. Everything worked fine.
> >>>>>>
> >>>>>> By the way, as I use getNodeValue and getNodeName to process and
> >>>>>>
> >>> assign
> >>>
> >>>>>> them
> >>>>>> to my C++ structures I need to parse the XMLCh* returned value to
> >>>>>> String^
> >>>>>> buy I couldn't find any way to do it. Any idea?
> >>>>>>
> >>>>>> Jesse,
> >>>>>> That's a good question..xD. There are many reasons why I am trying
> >>>>>>
> >>> to
> >>>
> >>>>>> use
> >>>>>> Xerces in order to parse and create XML files. Maybe you'll find
> >>>>>>
> >>> them
> >>>
> >>>>>> stupid.
> >>>>>>
> >>>>>> Firstly, I am an absolute newbie with C++ as with Xerces (as you
> >>>>>>
> >>> have
> >>>
> >>>>>> already realized). So, I did no research on XML classes offered by
> >>>>>>
> >>> the
> >>>
> >>>>>> .NET
> >>>>>> framework as I didn't know them.
> >>>>>> Secondly, I am developing an application based on a previous
> version
> >>>>>> which
> >>>>>> was developed by another person, who based his app on Xerces to
> >>>>>>
> >>> parse
> >>>
> >>>>>> XML
> >>>>>> files. The problem is that his design didn't take into account
> >>>>>>
> >>> creating
> >>>
> >>>>>> or
> >>>>>> writing on XML files, only parsing and reading, so he used the SAX
> >>>>>>
> >>> API.
> >>>
> >>>>>> Then, I had to switch from SAX to DOM and facing all the problems
> it
> >>>>>> implies
> >>>>>> (creating a NEW app).
> >>>>>> Thirdly, I thought I could find some help if I based my design on a
> >>>>>>
> >>> open
> >>>
> >>>>>> source solution like Xerces is, and here it is.
> >>>>>>
> >>>>>> Then, if you tell me that it is worth for me working with the
> >>>>>>
> >>> System:XML
> >>>
> >>>>>> files, then I would think about it..haha. But then, what is Xerces
> >>>>>>
> >>> for
> >>>
> >>>>>> if
> >>>>>> everybody can manage their XML files with these classes?
> >>>>>>
> >>>>>> Cheers,
> >>>>>> Javi
> >>>>>>
> >>>>>> 2007/11/28, Jesse Pelton < jsp@pkc.com>:
> >>>>>>
> >>>>>>
> >>>>>>> Just out of curiosity, if you're using managed code, why aren't
> you
> >>>>>>>
> >>>>>>>
> >>>>>> using
> >>>>>>
> >>>>>>
> >>>>>>> the System.XML classes?
> >>>>>>>
> >>>>>>> -----Original Message-----
> >>>>>>> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
> >>>>>>> Sent: Wednesday, November 28, 2007 11:03 AM
> >>>>>>> To: c-users@xerces.apache.org
> >>>>>>> Subject: Re: How to parse using DOM
> >>>>>>>
> >>>>>>> Hi there.
> >>>>>>>
> >>>>>>> Now I can compile the source code file where I have implemented
> (or
> >>>>>>>
> >>>>>>>
> >>>>>> tried
> >>>>>>
> >>>>>>
> >>>>>>> it...) the DOM parser, some errors have appeared. As they seem
> >>>>>>>
> >>> quite
> >>>
> >>>>>>> simple
> >>>>>>> I hope you could help me again:
> >>>>>>>
> >>>>>>> The method in file.cpp is like this (I have followed the
> guidelines
> >>>>>>> < http://xerces.apache.org/xerces-c/program-dom.html>on Xerces
> >>>>>>>
> >>> site,
> >>>
> >>>>>> except
> >>>>>>
> >>>>>>
> >>>>>>> for the exception treatment...):
> >>>>>>>
> >>>>>>> void contents_manager::load_guide(String^ xml_path){
> >>>>>>>
> >>>>>>>     XMLPlatformUtils::Initialize();
> >>>>>>>     XercesDOMParser* parser = new XercesDOMParser();
> >>>>>>>
> >>>>>>>     parser->parse(xml_path);
> >>>>>>>     DOMNode* root = parser->getDocument(); //child_aux1 will be
> the
> >>>>>>>
> >>>>>>>
> >>>>>> first
> >>>>>>
> >>>>>>
> >>>>>>> child of root
> >>>>>>>     DOMNode* child_aux1, child_aux2, child_aux3, child_aux4,
> >>>>>>>
> >>>>>>>
> >>>>>> child_aux5,
> >>>>>>
> >>>>>>
> >>>>>>> child_aux6, child_aux7; // Compiling errors referring to this line
> >>>>>>>
> >>>>>>>        //...
> >>>>>>>
> >>>>>>> In file.h this is included:
> >>>>>>>
> >>>>>>> #include "../include/gincludes.h"
> >>>>>>> #include "../content/content.h"
> >>>>>>> #include <xercesc/dom/DOM.hpp>
> >>>>>>> #include <xercesc/dom/DOMImplementation.hpp>
> >>>>>>> #include <xercesc/dom/DOMImplementationLS.hpp>
> >>>>>>> #include <xercesc/dom/DOMWriter.hpp>
> >>>>>>> #include <xercesc/util/PlatformUtils.hpp>
> >>>>>>> #include <xercesc/parsers/XercesDOMParser.hpp>
> >>>>>>> #include <xercesc/dom/DOM.hpp>
> >>>>>>> #include <xercesc/util/XMLString.hpp>
> >>>>>>> #include <xercesc/util/PlatformUtils.hpp>
> >>>>>>>
> >>>>>>> using namespace System;
> >>>>>>>
> >>>>>>> XERCES_CPP_NAMESPACE_USE
> >>>>>>>
> >>>>>>> // class definition...
> >>>>>>>
> >>>>>>> Then, when compiling a lot of errors appear saying that it can not
> >>>>>>>
> >>> be
> >>>
> >>>>>> done
> >>>>>>
> >>>>>>
> >>>>>>> as I am working with abstracts, referring to the previous red
> >>>>>>>
> >>> line...
> >>>
> >>>>>>> 1>.\contents_manager.cpp(17) : error C2259: xercesc_2_8::DOMNode'
> :
> >>>>>>>
> >>> no
> >>>
> >>>>>> se
> >>>>>>
> >>>>>>
> >>>>>>> puede crear una instancia de una clase abstract
> >>>>>>> 1>        debido a los siguientes miembros:
> >>>>>>> 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeName(void)
> >>>>>>>
> >>> const'
> >>>
> >>>>>> :
> >>>>>>
> >>>>>>
> >>>>>>> es
> >>>>>>> abstracto
> >>>>>>> 1>        D:\Ser teleco
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>
> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(246)
> >>>
> >>>
> >>>>>>> : vea la declaración de 'xercesc_2_8::DOMNode::getNodeName'
> >>>>>>> 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeValue(void)
> >>>>>>>
> >>>>>>>
> >>>>>> const' :
> >>>>>>
> >>>>>>
> >>>>>>> es
> >>>>>>> abstracto
> >>>>>>> 1>        D:\Ser teleco
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>
> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(255)
> >>>
> >>>
> >>>>>>> : vea la declaración de 'xercesc_2_8::DOMNode::getNodeValue'
> >>>>>>> 1>        'short xercesc_2_8::DOMNode::getNodeType(void) const' :
> >>>>>>>
> >>> es
> >>>
> >>>>>>> abstracto
> >>>>>>> ...
> >>>>>>>
> >>>>>>> Any idea of what I need to do regarding this error?
> >>>>>>>
> >>>>>>>
> >>>>>>> By the way, as you may have seen on the arguments of my method,
> the
> >>>>>>>
> >>>>>>> name/path of the XML file is received with String^ type, so, as I
> >>>>>>>
> >>> need
> >>>
> >>>>>> to
> >>>>>>
> >>>>>>
> >>>>>>> have a char* as an argument for parse->parse(file_name), how can I
> >>>>>>>
> >>>>>>>
> >>>>>> parse
> >>>>>>
> >>>>>>
> >>>>>>> it?
> >>>>>>>
> >>>>>>> Thank you very much,
> >>>>>>>
> >>>>>>> Javi
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> 2007/11/28, Sven Bauhan <sv...@ast.dfs.de>:
> >>>>>>>
> >>>>>>>
> >>>>>>>>> This is not true.  std::string and UTF-8 are fully compatible,
> as
> >>>>>>>>>
> >>>>>> long
> >>>>>>
> >>>>>>
> >>>>>>>> as
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> you make no assumptions about chopping things up at arbitrary
> >>>>>>>>>
> >>>>>>>>>
> >>>>>> indices,
> >>>>>>
> >>>>>>
> >>>>>>>> or
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> the relationship of Unicode code points and UTF-8 code
> units.  At
> >>>>>>>>>
> >>>>>>>>>
> >>>>>> any
> >>>>>>
> >>>>>>
> >>>>>>>> rate,
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> with a double-byte or multi-byte locale code page, you'd have
> the
> >>>>>>>>>
> >>>>>>>>>
> >>>>>> same
> >>>>>>
> >>>>>>
> >>>>>>>>> issues.
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> I do not really understand what you want to say here. As far as I
> >>>>>>>>
> >>>>>>>>
> >>>>>> know
> >>>>>>
> >>>>>>
> >>>>>>>> std::string stores strings in single byte units. In UTF-8 the
> >>>>>>>>
> >>> units
> >>>
> >>>>>> have
> >>>>>>
> >>>>>>
> >>>>>>>> variable length between 1 and 4 bytes. So I cannot see a match
> >>>>>>>>
> >>> here.
> >>>
> >>>>>>>> I thought to use UTF-8 with the STL you need something like
> >>>>>>>> std::basic_string<UTFChar>.
> >>>>>>>>
> >>>>>>>> Could you tell me, how to transcode the XMLChar* correctly using
> >>>>>>>>
> >>>>>>>>
> >>>>>> UTF-8?
> >>>>>>
> >>>>>>
> >>>>>>>> Sven
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>
> >>>>
> >>>
> >
> >
>
>

Re: How to parse using DOM

Posted by Alberto Massari <am...@datadirect.com>.
Javier Gálvez Guerrero wrote:
> Sorry, I didn't find the "additional libraries" but now these to lib's are
> added. However, now appear 10 errors...(before, they were 74).
>
> Creando archivo temporal "d:\Ser teleco
> mola\IPTV\Aplicación\Desarrollo\dIPTV\contents_manager\Debug\RSP00000716012284764.rsp"
> con contenido
> [
> /OUT:"D:\Ser teleco
> mola\IPTV\Aplicación\Desarrollo\dIPTV\Debug\contents_manager.exe"
> /INCREMENTAL /LIBPATH:"D:\Ser teleco
> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\lib" /MANIFEST
> /MANIFESTFILE:"Debug\contents_manager.exe.intermediate.manifest"
> /DEBUG /ASSEMBLYDEBUG /PDB:"d:\Ser teleco
> mola\IPTV\Aplicación\Desarrollo\dIPTV\debug\contents_manager.pdb"
> /SUBSYSTEM:CONSOLE /MACHINE:X86 /FIXED:No xerces-c_2.lib
> xerces-c_2D.lib kernel32.lib
>
> ".\Debug\contents_manager.obj"
> ]
> Creando línea de comandos "link.exe @"d:\Ser teleco
> mola\IPTV\Aplicación\Desarrollo\dIPTV\contents_manager\Debug\RSP00000716012284764.rsp"
> /NOLOGO /ERRORREPORT:PROMPT"
>
> Ventana Resultados
>
> Vinculando...
> contents_manager.obj : warning LNK4248: símbolo (token) de typeref sin
> resolver (01000019) para 'xercesc_2_8.XMLValidator'; no se puede
> ejecutar la imagen
> contents_manager.obj : warning LNK4248: símbolo (token) de typeref sin
> resolver (0100001A) para 'xercesc_2_8.XMLGrammarPool'; no se puede
> ejecutar la imagen
>   
I guess you meant writing xercesc_2_8::XMLGrammarPool (i.e. "::" instead 
of ".")
> contents_manager.obj : error LNK2028: se hace referencia al símbolo
> (token) sin resolver (0A00043C) "public: __thiscall
> content::content(class std::basic_string,class std::allocator >)"
> (??0content@@$$FQAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
> en la función "public: class content __thiscall
> contents_manager::get_content(class std::basic_string,class
> std::allocator >)"
> (?get_content@contents_manager@@$$FQAE?AVcontent@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
> contents_manager.obj : error LNK2028: se hace referencia al símbolo
> (token) sin resolver (0A00043D) "public: __thiscall
> content::content(void)" (??0content@@$$FQAE@XZ) en la función "public:
> class content __thiscall contents_manager::get_content(class
> std::basic_string,class std::allocator >)"
> (?get_content@contents_manager@@$$FQAE?AVcontent@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
> ...
>   
You are including a library that exposes a contents_manager class, but 
you didn't add the corresponding LIB file in the 'additional libraries' 
(you should know the name of the library, contents_manager is not part 
of Xerces)
> MSVCRTD.lib(crtexe.obj) : error LNK2019: símbolo externo _main sin
> resolver al que se hace referencia en la función ___tmainCRTStartup
> D:\Ser teleco mola\IPTV\Aplicación\Desarrollo\dIPTV\Debug\contents_manager.exe
>   
Have you written a main() method?

Alberto
> : fatal error LNK1120: 9 externos sin resolver
>
>
> Should I declare anything like an extern????
>
> Javi
>
>
> 2007/11/29, Javier Gálvez Guerrero <du...@gmail.com>:
>   
>> I have added the two lib paths in Tools | Options | Project Solutions |
>> VC++ Directories (selecting Library files) and Project | Properities |
>> Linker | General | Additional library folders (Selecting the "All
>> configurations" on Configuration combo on top left.
>>
>> And in the BuildLog.htm file appears this:
>>
>>
>> Creando archivo temporal "d:\Ser teleco mola\IPTV\Aplicación\Desarrollo\dIPTV\contents_manager\Debug\RSP00000416012186844.rsp" con contenido
>>
>> [
>> /OUT:"D:\Ser teleco mola\IPTV\Aplicación\Desarrollo\dIPTV\Debug\contents_manager.exe" /INCREMENTAL /LIBPATH:"D:\Ser teleco mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\lib"
>>  /MANIFEST /MANIFESTFILE:"Debug\contents_manager.exe.intermediate.manifest" /DEBUG /ASSEMBLYDEBUG /PDB:"d:\Ser teleco mola\IPTV\Aplicación\Desarrollo\dIPTV\debug\contents_manager.pdb" /SUBSYSTEM:CONSOLE /MACHINE:X86 /FIXED:No
>> kernel32.lib
>>
>> ".\Debug\contents_manager.obj"
>> ]
>> Creando línea de comandos "link.exe @"d:\Ser teleco mola\IPTV\Aplicación\Desarrollo\dIPTV\contents_manager\Debug\RSP00000416012186844.rsp" /NOLOGO /ERRORREPORT:PROMPT"
>>
>>
>>
>> So it seems I have added properly the folder but it does not work. This
>> folder contains xerces_c_2.lib, xerces_c_2D.lib and static(2) and depdom (4)
>> extensions, 8 files.
>>
>> I don't know if I need to configure anything more... I am so sorry, but
>> can you help me, please? I promise you that as soon as I can link properly I
>> will ask more "interesting" questions..haha.
>>
>> Thank you a lot,
>> Javi
>>
>>
>> 2007/11/29, Alberto Massari <am...@datadirect.com>:
>>     
>>> Javier,
>>> the same operation you did for the include folder should be done for the
>>> lib folder (using the Link property page of the Project properties if
>>> you want to fix just this project, or using the VC++ Directories
>>> property page in the Tools | Options menu, after selecting Library files
>>> in the combo box).
>>> In case you didn't already do it, you also need to list xerces_2.lib
>>> (for release builds) and xerces_2D.lib (for debug builds) in the
>>> 'additional libraries' entry of the project properties.
>>>
>>> Alberto
>>>
>>> Javier Gálvez Guerrero wrote:
>>>       
>>>> I think that the attachement doesn't work properly, so I'll copy paste
>>>>         
>>> the
>>>       
>>>> first outputs:
>>>>
>>>> Vinculando... contents_manager.obj : warning LNK4248: símbolo (token)
>>>>         
>>> de
>>>       
>>>> typeref sin resolver (01000019) para 'xercesc_2_8.XMLValidator'; no se
>>>>         
>>> puede
>>>       
>>>> ejecutar la imagen contents_manager.obj: warning LNK4248: símbolo
>>>>         
>>> (token) de
>>>       
>>>> typeref sin resolver (0100001A) para 'xercesc_2_8.XMLGrammarPool'; no
>>>>         
>>> se
>>>       
>>>> puede ejecutar la imagen contents_manager.obj : error LNK2028: se hace
>>>> referencia al símbolo (token) sin resolver (0A0003AE) "public: class
>>>> xercesc_2_8::DOMDocument * __thiscall
>>>> xercesc_2_8::AbstractDOMParser::getDocument(void)" (?getDocument@
>>>> AbstractDOMParser@xercesc_2_8@@$$FQAEPAVDOMDocument@2@XZ) en la
>>>>         
>>> función
>>>       
>>>> "public: void __thiscall contents_manager::load_guide(class
>>>> std::basic_string,class std::allocator >)"
>>>> (?load_guide@contents_manager@@$$FQAEXV?$basic_string@
>>>>         
>>> DU?$char_traits@D
>>>       
>>>> @std@@V?$allocator@D@2@@std@@@Z)
>>>>
>>>> Sorry for the inconvenience,
>>>> Javi
>>>>
>>>> 2007/11/28, Javier Gálvez Guerrero <du...@gmail.com>:
>>>>
>>>>         
>>>>> Should I configure anything for the linking files as I did with the
>>>>> Include?
>>>>>
>>>>> I have compiled my code with no errors, but at the time of linking
>>>>>           
>>> appear
>>>       
>>>>> lots of errors (BuildLog.htm attached).
>>>>>
>>>>> Thank you,
>>>>> Javi
>>>>>
>>>>> PS: Jesse, thanks a lot for your explanation about System.XML and its
>>>>> features. I am trying to design an application as multiplatform as
>>>>>           
>>> possible
>>>       
>>>>> and now that I have started with Xerces I would like to use it. But
>>>>>           
>>> it's
>>>       
>>>>> good to know all the alternatives out there. =).
>>>>>
>>>>>
>>>>>
>>>>> 2007/11/28, Jesse Pelton <js...@pkc.com>:
>>>>>
>>>>>           
>>>>>> Regarding System.XML versus Xerces: Xerces exists to provide a
>>>>>>             
>>> solid,
>>>       
>>>>>> open-source, cross-platform implementation of certain XML standards
>>>>>>             
>>> for C++
>>>       
>>>>>> developers.  Almost all C++ developers are using unmanaged code; I
>>>>>>             
>>> think
>>>       
>>>>>> you're the first I've heard of using Xerces with managed C++.
>>>>>>
>>>>>> To the extent that you're in a managed-code environment, Mono's
>>>>>> implementation of System.XML may fulfill the same requirements.  If
>>>>>> you're targeting Windows exclusively, the cross-platform issue is of
>>>>>>             
>>> no
>>>       
>>>>>> consequence; you'll use the Microsoft implementation.  My
>>>>>>             
>>> understanding is
>>>       
>>>>>> that System.XML is well-designed and robust, but I can't vouch for
>>>>>>             
>>> that
>>>       
>>>>>> myself.  That leaves openness; if that's not important for your
>>>>>>             
>>> project,
>>>       
>>>>>> System.XML would probably be at least as good a fit as Xerces (and I
>>>>>>             
>>>>>> imagine there's a large community of managed code developers who can
>>>>>>             
>>> help
>>>       
>>>>>> you out, though not one of them is as good as Alberto).  Using
>>>>>> System.XML would avoid redundancy: you wouldn't have to distribute,
>>>>>>             
>>> and
>>>       
>>>>>> your developers wouldn't have to understand, an additional library.
>>>>>>
>>>>>> This is not to say that you shouldn't use Xerces; it's a great
>>>>>> library.  Just know your options.
>>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
>>>>>> Sent: Wednesday, November 28, 2007 12:15 PM
>>>>>> To: c-users@xerces.apache.org
>>>>>> Subject: Re: How to parse using DOM
>>>>>>
>>>>>> Alberto,
>>>>>> Thanks again. Everything worked fine.
>>>>>>
>>>>>> By the way, as I use getNodeValue and getNodeName to process and
>>>>>>             
>>> assign
>>>       
>>>>>> them
>>>>>> to my C++ structures I need to parse the XMLCh* returned value to
>>>>>> String^
>>>>>> buy I couldn't find any way to do it. Any idea?
>>>>>>
>>>>>> Jesse,
>>>>>> That's a good question..xD. There are many reasons why I am trying
>>>>>>             
>>> to
>>>       
>>>>>> use
>>>>>> Xerces in order to parse and create XML files. Maybe you'll find
>>>>>>             
>>> them
>>>       
>>>>>> stupid.
>>>>>>
>>>>>> Firstly, I am an absolute newbie with C++ as with Xerces (as you
>>>>>>             
>>> have
>>>       
>>>>>> already realized). So, I did no research on XML classes offered by
>>>>>>             
>>> the
>>>       
>>>>>> .NET
>>>>>> framework as I didn't know them.
>>>>>> Secondly, I am developing an application based on a previous version
>>>>>> which
>>>>>> was developed by another person, who based his app on Xerces to
>>>>>>             
>>> parse
>>>       
>>>>>> XML
>>>>>> files. The problem is that his design didn't take into account
>>>>>>             
>>> creating
>>>       
>>>>>> or
>>>>>> writing on XML files, only parsing and reading, so he used the SAX
>>>>>>             
>>> API.
>>>       
>>>>>> Then, I had to switch from SAX to DOM and facing all the problems it
>>>>>> implies
>>>>>> (creating a NEW app).
>>>>>> Thirdly, I thought I could find some help if I based my design on a
>>>>>>             
>>> open
>>>       
>>>>>> source solution like Xerces is, and here it is.
>>>>>>
>>>>>> Then, if you tell me that it is worth for me working with the
>>>>>>             
>>> System:XML
>>>       
>>>>>> files, then I would think about it..haha. But then, what is Xerces
>>>>>>             
>>> for
>>>       
>>>>>> if
>>>>>> everybody can manage their XML files with these classes?
>>>>>>
>>>>>> Cheers,
>>>>>> Javi
>>>>>>
>>>>>> 2007/11/28, Jesse Pelton < jsp@pkc.com>:
>>>>>>
>>>>>>             
>>>>>>> Just out of curiosity, if you're using managed code, why aren't you
>>>>>>>
>>>>>>>               
>>>>>> using
>>>>>>
>>>>>>             
>>>>>>> the System.XML classes?
>>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
>>>>>>> Sent: Wednesday, November 28, 2007 11:03 AM
>>>>>>> To: c-users@xerces.apache.org
>>>>>>> Subject: Re: How to parse using DOM
>>>>>>>
>>>>>>> Hi there.
>>>>>>>
>>>>>>> Now I can compile the source code file where I have implemented (or
>>>>>>>
>>>>>>>               
>>>>>> tried
>>>>>>
>>>>>>             
>>>>>>> it...) the DOM parser, some errors have appeared. As they seem
>>>>>>>               
>>> quite
>>>       
>>>>>>> simple
>>>>>>> I hope you could help me again:
>>>>>>>
>>>>>>> The method in file.cpp is like this (I have followed the guidelines
>>>>>>> < http://xerces.apache.org/xerces-c/program-dom.html>on Xerces
>>>>>>>               
>>> site,
>>>       
>>>>>> except
>>>>>>
>>>>>>             
>>>>>>> for the exception treatment...):
>>>>>>>
>>>>>>> void contents_manager::load_guide(String^ xml_path){
>>>>>>>
>>>>>>>     XMLPlatformUtils::Initialize();
>>>>>>>     XercesDOMParser* parser = new XercesDOMParser();
>>>>>>>
>>>>>>>     parser->parse(xml_path);
>>>>>>>     DOMNode* root = parser->getDocument(); //child_aux1 will be the
>>>>>>>
>>>>>>>               
>>>>>> first
>>>>>>
>>>>>>             
>>>>>>> child of root
>>>>>>>     DOMNode* child_aux1, child_aux2, child_aux3, child_aux4,
>>>>>>>
>>>>>>>               
>>>>>> child_aux5,
>>>>>>
>>>>>>             
>>>>>>> child_aux6, child_aux7; // Compiling errors referring to this line
>>>>>>>
>>>>>>>        //...
>>>>>>>
>>>>>>> In file.h this is included:
>>>>>>>
>>>>>>> #include "../include/gincludes.h"
>>>>>>> #include "../content/content.h"
>>>>>>> #include <xercesc/dom/DOM.hpp>
>>>>>>> #include <xercesc/dom/DOMImplementation.hpp>
>>>>>>> #include <xercesc/dom/DOMImplementationLS.hpp>
>>>>>>> #include <xercesc/dom/DOMWriter.hpp>
>>>>>>> #include <xercesc/util/PlatformUtils.hpp>
>>>>>>> #include <xercesc/parsers/XercesDOMParser.hpp>
>>>>>>> #include <xercesc/dom/DOM.hpp>
>>>>>>> #include <xercesc/util/XMLString.hpp>
>>>>>>> #include <xercesc/util/PlatformUtils.hpp>
>>>>>>>
>>>>>>> using namespace System;
>>>>>>>
>>>>>>> XERCES_CPP_NAMESPACE_USE
>>>>>>>
>>>>>>> // class definition...
>>>>>>>
>>>>>>> Then, when compiling a lot of errors appear saying that it can not
>>>>>>>               
>>> be
>>>       
>>>>>> done
>>>>>>
>>>>>>             
>>>>>>> as I am working with abstracts, referring to the previous red
>>>>>>>               
>>> line...
>>>       
>>>>>>> 1>.\contents_manager.cpp(17) : error C2259: xercesc_2_8::DOMNode' :
>>>>>>>               
>>> no
>>>       
>>>>>> se
>>>>>>
>>>>>>             
>>>>>>> puede crear una instancia de una clase abstract
>>>>>>> 1>        debido a los siguientes miembros:
>>>>>>> 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeName(void)
>>>>>>>               
>>> const'
>>>       
>>>>>> :
>>>>>>
>>>>>>             
>>>>>>> es
>>>>>>> abstracto
>>>>>>> 1>        D:\Ser teleco
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>               
>>> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(246)
>>>
>>>       
>>>>>>> : vea la declaración de 'xercesc_2_8::DOMNode::getNodeName'
>>>>>>> 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeValue(void)
>>>>>>>
>>>>>>>               
>>>>>> const' :
>>>>>>
>>>>>>             
>>>>>>> es
>>>>>>> abstracto
>>>>>>> 1>        D:\Ser teleco
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>               
>>> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(255)
>>>
>>>       
>>>>>>> : vea la declaración de 'xercesc_2_8::DOMNode::getNodeValue'
>>>>>>> 1>        'short xercesc_2_8::DOMNode::getNodeType(void) const' :
>>>>>>>               
>>> es
>>>       
>>>>>>> abstracto
>>>>>>> ...
>>>>>>>
>>>>>>> Any idea of what I need to do regarding this error?
>>>>>>>
>>>>>>>
>>>>>>> By the way, as you may have seen on the arguments of my method, the
>>>>>>>               
>>>>>>> name/path of the XML file is received with String^ type, so, as I
>>>>>>>               
>>> need
>>>       
>>>>>> to
>>>>>>
>>>>>>             
>>>>>>> have a char* as an argument for parse->parse(file_name), how can I
>>>>>>>
>>>>>>>               
>>>>>> parse
>>>>>>
>>>>>>             
>>>>>>> it?
>>>>>>>
>>>>>>> Thank you very much,
>>>>>>>
>>>>>>> Javi
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> 2007/11/28, Sven Bauhan <sv...@ast.dfs.de>:
>>>>>>>
>>>>>>>               
>>>>>>>>> This is not true.  std::string and UTF-8 are fully compatible, as
>>>>>>>>>                   
>>>>>> long
>>>>>>
>>>>>>             
>>>>>>>> as
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> you make no assumptions about chopping things up at arbitrary
>>>>>>>>>
>>>>>>>>>                   
>>>>>> indices,
>>>>>>
>>>>>>             
>>>>>>>> or
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> the relationship of Unicode code points and UTF-8 code units.  At
>>>>>>>>>
>>>>>>>>>                   
>>>>>> any
>>>>>>
>>>>>>             
>>>>>>>> rate,
>>>>>>>>
>>>>>>>>                 
>>>>>>>>> with a double-byte or multi-byte locale code page, you'd have the
>>>>>>>>>
>>>>>>>>>                   
>>>>>> same
>>>>>>
>>>>>>             
>>>>>>>>> issues.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                   
>>>>>>>> I do not really understand what you want to say here. As far as I
>>>>>>>>
>>>>>>>>                 
>>>>>> know
>>>>>>
>>>>>>             
>>>>>>>> std::string stores strings in single byte units. In UTF-8 the
>>>>>>>>                 
>>> units
>>>       
>>>>>> have
>>>>>>
>>>>>>             
>>>>>>>> variable length between 1 and 4 bytes. So I cannot see a match
>>>>>>>>                 
>>> here.
>>>       
>>>>>>>> I thought to use UTF-8 with the STL you need something like
>>>>>>>> std::basic_string<UTFChar>.
>>>>>>>>
>>>>>>>> Could you tell me, how to transcode the XMLChar* correctly using
>>>>>>>>
>>>>>>>>                 
>>>>>> UTF-8?
>>>>>>
>>>>>>             
>>>>>>>> Sven
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>           
>>>>         
>>>       
>
>   


Re: How to parse using DOM

Posted by Javier Gálvez Guerrero <du...@gmail.com>.
Sorry, I didn't find the "additional libraries" but now these to lib's are
added. However, now appear 10 errors...(before, they were 74).

Creando archivo temporal "d:\Ser teleco
mola\IPTV\Aplicación\Desarrollo\dIPTV\contents_manager\Debug\RSP00000716012284764.rsp"
con contenido
[
/OUT:"D:\Ser teleco
mola\IPTV\Aplicación\Desarrollo\dIPTV\Debug\contents_manager.exe"
/INCREMENTAL /LIBPATH:"D:\Ser teleco
mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\lib" /MANIFEST
/MANIFESTFILE:"Debug\contents_manager.exe.intermediate.manifest"
/DEBUG /ASSEMBLYDEBUG /PDB:"d:\Ser teleco
mola\IPTV\Aplicación\Desarrollo\dIPTV\debug\contents_manager.pdb"
/SUBSYSTEM:CONSOLE /MACHINE:X86 /FIXED:No xerces-c_2.lib
xerces-c_2D.lib kernel32.lib

".\Debug\contents_manager.obj"
]
Creando línea de comandos "link.exe @"d:\Ser teleco
mola\IPTV\Aplicación\Desarrollo\dIPTV\contents_manager\Debug\RSP00000716012284764.rsp"
/NOLOGO /ERRORREPORT:PROMPT"

Ventana Resultados

Vinculando...
contents_manager.obj : warning LNK4248: símbolo (token) de typeref sin
resolver (01000019) para 'xercesc_2_8.XMLValidator'; no se puede
ejecutar la imagen
contents_manager.obj : warning LNK4248: símbolo (token) de typeref sin
resolver (0100001A) para 'xercesc_2_8.XMLGrammarPool'; no se puede
ejecutar la imagen
contents_manager.obj : error LNK2028: se hace referencia al símbolo
(token) sin resolver (0A00043C) "public: __thiscall
content::content(class std::basic_string,class std::allocator >)"
(??0content@@$$FQAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
en la función "public: class content __thiscall
contents_manager::get_content(class std::basic_string,class
std::allocator >)"
(?get_content@contents_manager@@$$FQAE?AVcontent@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
contents_manager.obj : error LNK2028: se hace referencia al símbolo
(token) sin resolver (0A00043D) "public: __thiscall
content::content(void)" (??0content@@$$FQAE@XZ) en la función "public:
class content __thiscall contents_manager::get_content(class
std::basic_string,class std::allocator >)"
(?get_content@contents_manager@@$$FQAE?AVcontent@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
...

MSVCRTD.lib(crtexe.obj) : error LNK2019: símbolo externo _main sin
resolver al que se hace referencia en la función ___tmainCRTStartup
D:\Ser teleco mola\IPTV\Aplicación\Desarrollo\dIPTV\Debug\contents_manager.exe
: fatal error LNK1120: 9 externos sin resolver


Should I declare anything like an extern????

Javi


2007/11/29, Javier Gálvez Guerrero <du...@gmail.com>:
>
> I have added the two lib paths in Tools | Options | Project Solutions |
> VC++ Directories (selecting Library files) and Project | Properities |
> Linker | General | Additional library folders (Selecting the "All
> configurations" on Configuration combo on top left.
>
> And in the BuildLog.htm file appears this:
>
>
> Creando archivo temporal "d:\Ser teleco mola\IPTV\Aplicación\Desarrollo\dIPTV\contents_manager\Debug\RSP00000416012186844.rsp" con contenido
>
> [
> /OUT:"D:\Ser teleco mola\IPTV\Aplicación\Desarrollo\dIPTV\Debug\contents_manager.exe" /INCREMENTAL /LIBPATH:"D:\Ser teleco mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\lib"
>  /MANIFEST /MANIFESTFILE:"Debug\contents_manager.exe.intermediate.manifest" /DEBUG /ASSEMBLYDEBUG /PDB:"d:\Ser teleco mola\IPTV\Aplicación\Desarrollo\dIPTV\debug\contents_manager.pdb" /SUBSYSTEM:CONSOLE /MACHINE:X86 /FIXED:No
> kernel32.lib
>
> ".\Debug\contents_manager.obj"
> ]
> Creando línea de comandos "link.exe @"d:\Ser teleco mola\IPTV\Aplicación\Desarrollo\dIPTV\contents_manager\Debug\RSP00000416012186844.rsp" /NOLOGO /ERRORREPORT:PROMPT"
>
>
>
> So it seems I have added properly the folder but it does not work. This
> folder contains xerces_c_2.lib, xerces_c_2D.lib and static(2) and depdom (4)
> extensions, 8 files.
>
> I don't know if I need to configure anything more... I am so sorry, but
> can you help me, please? I promise you that as soon as I can link properly I
> will ask more "interesting" questions..haha.
>
> Thank you a lot,
> Javi
>
>
> 2007/11/29, Alberto Massari <am...@datadirect.com>:
> >
> > Javier,
> > the same operation you did for the include folder should be done for the
> > lib folder (using the Link property page of the Project properties if
> > you want to fix just this project, or using the VC++ Directories
> > property page in the Tools | Options menu, after selecting Library files
> > in the combo box).
> > In case you didn't already do it, you also need to list xerces_2.lib
> > (for release builds) and xerces_2D.lib (for debug builds) in the
> > 'additional libraries' entry of the project properties.
> >
> > Alberto
> >
> > Javier Gálvez Guerrero wrote:
> > > I think that the attachement doesn't work properly, so I'll copy paste
> > the
> > > first outputs:
> > >
> > > Vinculando... contents_manager.obj : warning LNK4248: símbolo (token)
> > de
> > > typeref sin resolver (01000019) para 'xercesc_2_8.XMLValidator'; no se
> > puede
> > > ejecutar la imagen contents_manager.obj: warning LNK4248: símbolo
> > (token) de
> > > typeref sin resolver (0100001A) para 'xercesc_2_8.XMLGrammarPool'; no
> > se
> > > puede ejecutar la imagen contents_manager.obj : error LNK2028: se hace
> > > referencia al símbolo (token) sin resolver (0A0003AE) "public: class
> > > xercesc_2_8::DOMDocument * __thiscall
> > > xercesc_2_8::AbstractDOMParser::getDocument(void)" (?getDocument@
> > > AbstractDOMParser@xercesc_2_8@@$$FQAEPAVDOMDocument@2@XZ) en la
> > función
> > > "public: void __thiscall contents_manager::load_guide(class
> > > std::basic_string,class std::allocator >)"
> > > (?load_guide@contents_manager@@$$FQAEXV?$basic_string@
> > DU?$char_traits@D
> > > @std@@V?$allocator@D@2@@std@@@Z)
> > >
> > > Sorry for the inconvenience,
> > > Javi
> > >
> > > 2007/11/28, Javier Gálvez Guerrero <du...@gmail.com>:
> > >
> > >> Should I configure anything for the linking files as I did with the
> > >> Include?
> > >>
> > >> I have compiled my code with no errors, but at the time of linking
> > appear
> > >> lots of errors (BuildLog.htm attached).
> > >>
> > >> Thank you,
> > >> Javi
> > >>
> > >> PS: Jesse, thanks a lot for your explanation about System.XML and its
> > >> features. I am trying to design an application as multiplatform as
> > possible
> > >> and now that I have started with Xerces I would like to use it. But
> > it's
> > >> good to know all the alternatives out there. =).
> > >>
> > >>
> > >>
> > >> 2007/11/28, Jesse Pelton <js...@pkc.com>:
> > >>
> > >>> Regarding System.XML versus Xerces: Xerces exists to provide a
> > solid,
> > >>> open-source, cross-platform implementation of certain XML standards
> > for C++
> > >>> developers.  Almost all C++ developers are using unmanaged code; I
> > think
> > >>> you're the first I've heard of using Xerces with managed C++.
> > >>>
> > >>> To the extent that you're in a managed-code environment, Mono's
> > >>> implementation of System.XML may fulfill the same requirements.  If
> > >>> you're targeting Windows exclusively, the cross-platform issue is of
> > no
> > >>> consequence; you'll use the Microsoft implementation.  My
> > understanding is
> > >>> that System.XML is well-designed and robust, but I can't vouch for
> > that
> > >>> myself.  That leaves openness; if that's not important for your
> > project,
> > >>> System.XML would probably be at least as good a fit as Xerces (and I
> >
> > >>> imagine there's a large community of managed code developers who can
> > help
> > >>> you out, though not one of them is as good as Alberto).  Using
> > >>> System.XML would avoid redundancy: you wouldn't have to distribute,
> > and
> > >>> your developers wouldn't have to understand, an additional library.
> > >>>
> > >>> This is not to say that you shouldn't use Xerces; it's a great
> > >>> library.  Just know your options.
> > >>>
> > >>> -----Original Message-----
> > >>> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
> > >>> Sent: Wednesday, November 28, 2007 12:15 PM
> > >>> To: c-users@xerces.apache.org
> > >>> Subject: Re: How to parse using DOM
> > >>>
> > >>> Alberto,
> > >>> Thanks again. Everything worked fine.
> > >>>
> > >>> By the way, as I use getNodeValue and getNodeName to process and
> > assign
> > >>> them
> > >>> to my C++ structures I need to parse the XMLCh* returned value to
> > >>> String^
> > >>> buy I couldn't find any way to do it. Any idea?
> > >>>
> > >>> Jesse,
> > >>> That's a good question..xD. There are many reasons why I am trying
> > to
> > >>> use
> > >>> Xerces in order to parse and create XML files. Maybe you'll find
> > them
> > >>> stupid.
> > >>>
> > >>> Firstly, I am an absolute newbie with C++ as with Xerces (as you
> > have
> > >>> already realized). So, I did no research on XML classes offered by
> > the
> > >>> .NET
> > >>> framework as I didn't know them.
> > >>> Secondly, I am developing an application based on a previous version
> > >>> which
> > >>> was developed by another person, who based his app on Xerces to
> > parse
> > >>> XML
> > >>> files. The problem is that his design didn't take into account
> > creating
> > >>> or
> > >>> writing on XML files, only parsing and reading, so he used the SAX
> > API.
> > >>> Then, I had to switch from SAX to DOM and facing all the problems it
> > >>> implies
> > >>> (creating a NEW app).
> > >>> Thirdly, I thought I could find some help if I based my design on a
> > open
> > >>> source solution like Xerces is, and here it is.
> > >>>
> > >>> Then, if you tell me that it is worth for me working with the
> > System:XML
> > >>> files, then I would think about it..haha. But then, what is Xerces
> > for
> > >>> if
> > >>> everybody can manage their XML files with these classes?
> > >>>
> > >>> Cheers,
> > >>> Javi
> > >>>
> > >>> 2007/11/28, Jesse Pelton < jsp@pkc.com>:
> > >>>
> > >>>> Just out of curiosity, if you're using managed code, why aren't you
> > >>>>
> > >>> using
> > >>>
> > >>>> the System.XML classes?
> > >>>>
> > >>>> -----Original Message-----
> > >>>> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
> > >>>> Sent: Wednesday, November 28, 2007 11:03 AM
> > >>>> To: c-users@xerces.apache.org
> > >>>> Subject: Re: How to parse using DOM
> > >>>>
> > >>>> Hi there.
> > >>>>
> > >>>> Now I can compile the source code file where I have implemented (or
> > >>>>
> > >>> tried
> > >>>
> > >>>> it...) the DOM parser, some errors have appeared. As they seem
> > quite
> > >>>> simple
> > >>>> I hope you could help me again:
> > >>>>
> > >>>> The method in file.cpp is like this (I have followed the guidelines
> > >>>> < http://xerces.apache.org/xerces-c/program-dom.html>on Xerces
> > site,
> > >>>>
> > >>> except
> > >>>
> > >>>> for the exception treatment...):
> > >>>>
> > >>>> void contents_manager::load_guide(String^ xml_path){
> > >>>>
> > >>>>     XMLPlatformUtils::Initialize();
> > >>>>     XercesDOMParser* parser = new XercesDOMParser();
> > >>>>
> > >>>>     parser->parse(xml_path);
> > >>>>     DOMNode* root = parser->getDocument(); //child_aux1 will be the
> > >>>>
> > >>> first
> > >>>
> > >>>> child of root
> > >>>>     DOMNode* child_aux1, child_aux2, child_aux3, child_aux4,
> > >>>>
> > >>> child_aux5,
> > >>>
> > >>>> child_aux6, child_aux7; // Compiling errors referring to this line
> > >>>>
> > >>>>        //...
> > >>>>
> > >>>> In file.h this is included:
> > >>>>
> > >>>> #include "../include/gincludes.h"
> > >>>> #include "../content/content.h"
> > >>>> #include <xercesc/dom/DOM.hpp>
> > >>>> #include <xercesc/dom/DOMImplementation.hpp>
> > >>>> #include <xercesc/dom/DOMImplementationLS.hpp>
> > >>>> #include <xercesc/dom/DOMWriter.hpp>
> > >>>> #include <xercesc/util/PlatformUtils.hpp>
> > >>>> #include <xercesc/parsers/XercesDOMParser.hpp>
> > >>>> #include <xercesc/dom/DOM.hpp>
> > >>>> #include <xercesc/util/XMLString.hpp>
> > >>>> #include <xercesc/util/PlatformUtils.hpp>
> > >>>>
> > >>>> using namespace System;
> > >>>>
> > >>>> XERCES_CPP_NAMESPACE_USE
> > >>>>
> > >>>> // class definition...
> > >>>>
> > >>>> Then, when compiling a lot of errors appear saying that it can not
> > be
> > >>>>
> > >>> done
> > >>>
> > >>>> as I am working with abstracts, referring to the previous red
> > line...
> > >>>>
> > >>>> 1>.\contents_manager.cpp(17) : error C2259: xercesc_2_8::DOMNode' :
> > no
> > >>>>
> > >>> se
> > >>>
> > >>>> puede crear una instancia de una clase abstract
> > >>>> 1>        debido a los siguientes miembros:
> > >>>> 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeName(void)
> > const'
> > >>>>
> > >>> :
> > >>>
> > >>>> es
> > >>>> abstracto
> > >>>> 1>        D:\Ser teleco
> > >>>>
> > >>>>
> > >>>>
> > >>>
> > mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(246)
> >
> > >>>
> > >>>> : vea la declaración de 'xercesc_2_8::DOMNode::getNodeName'
> > >>>> 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeValue(void)
> > >>>>
> > >>> const' :
> > >>>
> > >>>> es
> > >>>> abstracto
> > >>>> 1>        D:\Ser teleco
> > >>>>
> > >>>>
> > >>>>
> > >>>
> > mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(255)
> >
> > >>>
> > >>>> : vea la declaración de 'xercesc_2_8::DOMNode::getNodeValue'
> > >>>> 1>        'short xercesc_2_8::DOMNode::getNodeType(void) const' :
> > es
> > >>>> abstracto
> > >>>> ...
> > >>>>
> > >>>> Any idea of what I need to do regarding this error?
> > >>>>
> > >>>>
> > >>>> By the way, as you may have seen on the arguments of my method, the
> >
> > >>>> name/path of the XML file is received with String^ type, so, as I
> > need
> > >>>>
> > >>> to
> > >>>
> > >>>> have a char* as an argument for parse->parse(file_name), how can I
> > >>>>
> > >>> parse
> > >>>
> > >>>> it?
> > >>>>
> > >>>> Thank you very much,
> > >>>>
> > >>>> Javi
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >>>> 2007/11/28, Sven Bauhan <sv...@ast.dfs.de>:
> > >>>>
> > >>>>>> This is not true.  std::string and UTF-8 are fully compatible, as
> >
> > >>>>>>
> > >>> long
> > >>>
> > >>>>> as
> > >>>>>
> > >>>>>> you make no assumptions about chopping things up at arbitrary
> > >>>>>>
> > >>> indices,
> > >>>
> > >>>>> or
> > >>>>>
> > >>>>>> the relationship of Unicode code points and UTF-8 code units.  At
> > >>>>>>
> > >>> any
> > >>>
> > >>>>> rate,
> > >>>>>
> > >>>>>> with a double-byte or multi-byte locale code page, you'd have the
> > >>>>>>
> > >>> same
> > >>>
> > >>>>>> issues.
> > >>>>>>
> > >>>>>>
> > >>>>> I do not really understand what you want to say here. As far as I
> > >>>>>
> > >>> know
> > >>>
> > >>>>> std::string stores strings in single byte units. In UTF-8 the
> > units
> > >>>>>
> > >>> have
> > >>>
> > >>>>> variable length between 1 and 4 bytes. So I cannot see a match
> > here.
> > >>>>> I thought to use UTF-8 with the STL you need something like
> > >>>>> std::basic_string<UTFChar>.
> > >>>>>
> > >>>>> Could you tell me, how to transcode the XMLChar* correctly using
> > >>>>>
> > >>> UTF-8?
> > >>>
> > >>>>> Sven
> > >>>>>
> > >>>>>
> > >>
> > >>
> > >
> > >
> >
> >
>

Re: How to parse using DOM

Posted by Alberto Massari <am...@datadirect.com>.
Have you done also this?

> In case you didn't already do it, you also need to list xerces_2.lib
> (for release builds) and xerces_2D.lib (for debug builds) in the
> 'additional libraries' entry of the project properties.
>

Alberto

Javier Gálvez Guerrero wrote:
> I have added the two lib paths in Tools | Options | Project Solutions | VC++
> Directories (selecting Library files) and Project | Properities | Linker |
> General | Additional library folders (Selecting the "All configurations" on
> Configuration combo on top left.
>
> And in the BuildLog.htm file appears this:
>
>
> Creando archivo temporal "d:\Ser teleco
> mola\IPTV\Aplicación\Desarrollo\dIPTV\contents_manager\Debug\RSP00000416012186844.rsp"
> con contenido
> [
> /OUT:"D:\Ser teleco
> mola\IPTV\Aplicación\Desarrollo\dIPTV\Debug\contents_manager.exe"
> /INCREMENTAL /LIBPATH:"D:\Ser teleco
> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\lib" /MANIFEST
> /MANIFESTFILE:"Debug\contents_manager.exe.intermediate.manifest"
> /DEBUG /ASSEMBLYDEBUG /PDB:"d:\Ser teleco
> mola\IPTV\Aplicación\Desarrollo\dIPTV\debug\contents_manager.pdb"
> /SUBSYSTEM:CONSOLE /MACHINE:X86 /FIXED:No kernel32.lib
>
> ".\Debug\contents_manager.obj"
> ]
> Creando línea de comandos "link.exe @"d:\Ser teleco
> mola\IPTV\Aplicación\Desarrollo\dIPTV\contents_manager\Debug\RSP00000416012186844.rsp"
> /NOLOGO /ERRORREPORT:PROMPT"
>
>
>
> So it seems I have added properly the folder but it does not work. This
> folder contains xerces_c_2.lib, xerces_c_2D.lib and static(2) and depdom (4)
> extensions, 8 files.
>
> I don't know if I need to configure anything more... I am so sorry, but can
> you help me, please? I promise you that as soon as I can link properly I
> will ask more "interesting" questions..haha.
>
> Thank you a lot,
> Javi
>
>
> 2007/11/29, Alberto Massari <am...@datadirect.com>:
>   
>> Javier,
>> the same operation you did for the include folder should be done for the
>> lib folder (using the Link property page of the Project properties if
>> you want to fix just this project, or using the VC++ Directories
>> property page in the Tools | Options menu, after selecting Library files
>> in the combo box).
>> In case you didn't already do it, you also need to list xerces_2.lib
>> (for release builds) and xerces_2D.lib (for debug builds) in the
>> 'additional libraries' entry of the project properties.
>>
>> Alberto
>>
>> Javier Gálvez Guerrero wrote:
>>     
>>> I think that the attachement doesn't work properly, so I'll copy paste
>>>       
>> the
>>     
>>> first outputs:
>>>
>>> Vinculando... contents_manager.obj : warning LNK4248: símbolo (token) de
>>> typeref sin resolver (01000019) para 'xercesc_2_8.XMLValidator'; no se
>>>       
>> puede
>>     
>>> ejecutar la imagen contents_manager.obj: warning LNK4248: símbolo
>>>       
>> (token) de
>>     
>>> typeref sin resolver (0100001A) para 'xercesc_2_8.XMLGrammarPool'; no se
>>> puede ejecutar la imagen contents_manager.obj : error LNK2028: se hace
>>> referencia al símbolo (token) sin resolver (0A0003AE) "public: class
>>> xercesc_2_8::DOMDocument * __thiscall
>>> xercesc_2_8::AbstractDOMParser::getDocument(void)" (?getDocument@
>>> AbstractDOMParser@xercesc_2_8@@$$FQAEPAVDOMDocument@2@XZ) en la función
>>> "public: void __thiscall contents_manager::load_guide(class
>>> std::basic_string,class std::allocator >)"
>>> (?load_guide@contents_manager@@$$FQAEXV?$basic_string@DU?$char_traits@D
>>> @std@@V?$allocator@D@2@@std@@@Z)
>>>
>>> Sorry for the inconvenience,
>>> Javi
>>>
>>> 2007/11/28, Javier Gálvez Guerrero <du...@gmail.com>:
>>>
>>>       
>>>> Should I configure anything for the linking files as I did with the
>>>> Include?
>>>>
>>>> I have compiled my code with no errors, but at the time of linking
>>>>         
>> appear
>>     
>>>> lots of errors (BuildLog.htm attached).
>>>>
>>>> Thank you,
>>>> Javi
>>>>
>>>> PS: Jesse, thanks a lot for your explanation about System.XML and its
>>>> features. I am trying to design an application as multiplatform as
>>>>         
>> possible
>>     
>>>> and now that I have started with Xerces I would like to use it. But
>>>>         
>> it's
>>     
>>>> good to know all the alternatives out there. =).
>>>>
>>>>
>>>>
>>>> 2007/11/28, Jesse Pelton <js...@pkc.com>:
>>>>
>>>>         
>>>>> Regarding System.XML versus Xerces: Xerces exists to provide a solid,
>>>>> open-source, cross-platform implementation of certain XML standards
>>>>>           
>> for C++
>>     
>>>>> developers.  Almost all C++ developers are using unmanaged code; I
>>>>>           
>> think
>>     
>>>>> you're the first I've heard of using Xerces with managed C++.
>>>>>
>>>>> To the extent that you're in a managed-code environment, Mono's
>>>>> implementation of System.XML may fulfill the same requirements.  If
>>>>> you're targeting Windows exclusively, the cross-platform issue is of
>>>>>           
>> no
>>     
>>>>> consequence; you'll use the Microsoft implementation.  My
>>>>>           
>> understanding is
>>     
>>>>> that System.XML is well-designed and robust, but I can't vouch for
>>>>>           
>> that
>>     
>>>>> myself.  That leaves openness; if that's not important for your
>>>>>           
>> project,
>>     
>>>>> System.XML would probably be at least as good a fit as Xerces (and I
>>>>> imagine there's a large community of managed code developers who can
>>>>>           
>> help
>>     
>>>>> you out, though not one of them is as good as Alberto).  Using
>>>>> System.XML would avoid redundancy: you wouldn't have to distribute,
>>>>>           
>> and
>>     
>>>>> your developers wouldn't have to understand, an additional library.
>>>>>
>>>>> This is not to say that you shouldn't use Xerces; it's a great
>>>>> library.  Just know your options.
>>>>>
>>>>> -----Original Message-----
>>>>> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
>>>>> Sent: Wednesday, November 28, 2007 12:15 PM
>>>>> To: c-users@xerces.apache.org
>>>>> Subject: Re: How to parse using DOM
>>>>>
>>>>> Alberto,
>>>>> Thanks again. Everything worked fine.
>>>>>
>>>>> By the way, as I use getNodeValue and getNodeName to process and
>>>>>           
>> assign
>>     
>>>>> them
>>>>> to my C++ structures I need to parse the XMLCh* returned value to
>>>>> String^
>>>>> buy I couldn't find any way to do it. Any idea?
>>>>>
>>>>> Jesse,
>>>>> That's a good question..xD. There are many reasons why I am trying to
>>>>> use
>>>>> Xerces in order to parse and create XML files. Maybe you'll find them
>>>>> stupid.
>>>>>
>>>>> Firstly, I am an absolute newbie with C++ as with Xerces (as you have
>>>>> already realized). So, I did no research on XML classes offered by the
>>>>> .NET
>>>>> framework as I didn't know them.
>>>>> Secondly, I am developing an application based on a previous version
>>>>> which
>>>>> was developed by another person, who based his app on Xerces to parse
>>>>> XML
>>>>> files. The problem is that his design didn't take into account
>>>>>           
>> creating
>>     
>>>>> or
>>>>> writing on XML files, only parsing and reading, so he used the SAX
>>>>>           
>> API.
>>     
>>>>> Then, I had to switch from SAX to DOM and facing all the problems it
>>>>> implies
>>>>> (creating a NEW app).
>>>>> Thirdly, I thought I could find some help if I based my design on a
>>>>>           
>> open
>>     
>>>>> source solution like Xerces is, and here it is.
>>>>>
>>>>> Then, if you tell me that it is worth for me working with the
>>>>>           
>> System:XML
>>     
>>>>> files, then I would think about it..haha. But then, what is Xerces for
>>>>> if
>>>>> everybody can manage their XML files with these classes?
>>>>>
>>>>> Cheers,
>>>>> Javi
>>>>>
>>>>> 2007/11/28, Jesse Pelton <js...@pkc.com>:
>>>>>
>>>>>           
>>>>>> Just out of curiosity, if you're using managed code, why aren't you
>>>>>>
>>>>>>             
>>>>> using
>>>>>
>>>>>           
>>>>>> the System.XML classes?
>>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
>>>>>> Sent: Wednesday, November 28, 2007 11:03 AM
>>>>>> To: c-users@xerces.apache.org
>>>>>> Subject: Re: How to parse using DOM
>>>>>>
>>>>>> Hi there.
>>>>>>
>>>>>> Now I can compile the source code file where I have implemented (or
>>>>>>
>>>>>>             
>>>>> tried
>>>>>
>>>>>           
>>>>>> it...) the DOM parser, some errors have appeared. As they seem quite
>>>>>> simple
>>>>>> I hope you could help me again:
>>>>>>
>>>>>> The method in file.cpp is like this (I have followed the guidelines
>>>>>> < http://xerces.apache.org/xerces-c/program-dom.html>on Xerces site,
>>>>>>
>>>>>>             
>>>>> except
>>>>>
>>>>>           
>>>>>> for the exception treatment...):
>>>>>>
>>>>>> void contents_manager::load_guide(String^ xml_path){
>>>>>>
>>>>>>     XMLPlatformUtils::Initialize();
>>>>>>     XercesDOMParser* parser = new XercesDOMParser();
>>>>>>
>>>>>>     parser->parse(xml_path);
>>>>>>     DOMNode* root = parser->getDocument(); //child_aux1 will be the
>>>>>>
>>>>>>             
>>>>> first
>>>>>
>>>>>           
>>>>>> child of root
>>>>>>     DOMNode* child_aux1, child_aux2, child_aux3, child_aux4,
>>>>>>
>>>>>>             
>>>>> child_aux5,
>>>>>
>>>>>           
>>>>>> child_aux6, child_aux7; // Compiling errors referring to this line
>>>>>>
>>>>>>        //...
>>>>>>
>>>>>> In file.h this is included:
>>>>>>
>>>>>> #include "../include/gincludes.h"
>>>>>> #include "../content/content.h"
>>>>>> #include <xercesc/dom/DOM.hpp>
>>>>>> #include <xercesc/dom/DOMImplementation.hpp>
>>>>>> #include <xercesc/dom/DOMImplementationLS.hpp>
>>>>>> #include <xercesc/dom/DOMWriter.hpp>
>>>>>> #include <xercesc/util/PlatformUtils.hpp>
>>>>>> #include <xercesc/parsers/XercesDOMParser.hpp>
>>>>>> #include <xercesc/dom/DOM.hpp>
>>>>>> #include <xercesc/util/XMLString.hpp>
>>>>>> #include <xercesc/util/PlatformUtils.hpp>
>>>>>>
>>>>>> using namespace System;
>>>>>>
>>>>>> XERCES_CPP_NAMESPACE_USE
>>>>>>
>>>>>> // class definition...
>>>>>>
>>>>>> Then, when compiling a lot of errors appear saying that it can not be
>>>>>>
>>>>>>             
>>>>> done
>>>>>
>>>>>           
>>>>>> as I am working with abstracts, referring to the previous red line...
>>>>>>
>>>>>> 1>.\contents_manager.cpp(17) : error C2259: xercesc_2_8::DOMNode' :
>>>>>>             
>> no
>>     
>>>>> se
>>>>>
>>>>>           
>>>>>> puede crear una instancia de una clase abstract
>>>>>> 1>        debido a los siguientes miembros:
>>>>>> 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeName(void)
>>>>>>             
>> const'
>>     
>>>>> :
>>>>>
>>>>>           
>>>>>> es
>>>>>> abstracto
>>>>>> 1>        D:\Ser teleco
>>>>>>
>>>>>>
>>>>>>
>>>>>>             
>> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(246)
>>     
>>>>>> : vea la declaración de 'xercesc_2_8::DOMNode::getNodeName'
>>>>>> 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeValue(void)
>>>>>>
>>>>>>             
>>>>> const' :
>>>>>
>>>>>           
>>>>>> es
>>>>>> abstracto
>>>>>> 1>        D:\Ser teleco
>>>>>>
>>>>>>
>>>>>>
>>>>>>             
>> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(255)
>>     
>>>>>> : vea la declaración de 'xercesc_2_8::DOMNode::getNodeValue'
>>>>>> 1>        'short xercesc_2_8::DOMNode::getNodeType(void) const' : es
>>>>>> abstracto
>>>>>> ...
>>>>>>
>>>>>> Any idea of what I need to do regarding this error?
>>>>>>
>>>>>>
>>>>>> By the way, as you may have seen on the arguments of my method, the
>>>>>> name/path of the XML file is received with String^ type, so, as I
>>>>>>             
>> need
>>     
>>>>> to
>>>>>
>>>>>           
>>>>>> have a char* as an argument for parse->parse(file_name), how can I
>>>>>>
>>>>>>             
>>>>> parse
>>>>>
>>>>>           
>>>>>> it?
>>>>>>
>>>>>> Thank you very much,
>>>>>>
>>>>>> Javi
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> 2007/11/28, Sven Bauhan <sv...@ast.dfs.de>:
>>>>>>
>>>>>>             
>>>>>>>> This is not true.  std::string and UTF-8 are fully compatible, as
>>>>>>>>
>>>>>>>>                 
>>>>> long
>>>>>
>>>>>           
>>>>>>> as
>>>>>>>
>>>>>>>               
>>>>>>>> you make no assumptions about chopping things up at arbitrary
>>>>>>>>
>>>>>>>>                 
>>>>> indices,
>>>>>
>>>>>           
>>>>>>> or
>>>>>>>
>>>>>>>               
>>>>>>>> the relationship of Unicode code points and UTF-8 code units.  At
>>>>>>>>
>>>>>>>>                 
>>>>> any
>>>>>
>>>>>           
>>>>>>> rate,
>>>>>>>
>>>>>>>               
>>>>>>>> with a double-byte or multi-byte locale code page, you'd have the
>>>>>>>>
>>>>>>>>                 
>>>>> same
>>>>>
>>>>>           
>>>>>>>> issues.
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> I do not really understand what you want to say here. As far as I
>>>>>>>
>>>>>>>               
>>>>> know
>>>>>
>>>>>           
>>>>>>> std::string stores strings in single byte units. In UTF-8 the units
>>>>>>>
>>>>>>>               
>>>>> have
>>>>>
>>>>>           
>>>>>>> variable length between 1 and 4 bytes. So I cannot see a match here.
>>>>>>> I thought to use UTF-8 with the STL you need something like
>>>>>>> std::basic_string<UTFChar>.
>>>>>>>
>>>>>>> Could you tell me, how to transcode the XMLChar* correctly using
>>>>>>>
>>>>>>>               
>>>>> UTF-8?
>>>>>
>>>>>           
>>>>>>> Sven
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>         
>>>       
>>     
>
>   


Re: How to parse using DOM

Posted by Javier Gálvez Guerrero <du...@gmail.com>.
I have added the two lib paths in Tools | Options | Project Solutions | VC++
Directories (selecting Library files) and Project | Properities | Linker |
General | Additional library folders (Selecting the "All configurations" on
Configuration combo on top left.

And in the BuildLog.htm file appears this:


Creando archivo temporal "d:\Ser teleco
mola\IPTV\Aplicación\Desarrollo\dIPTV\contents_manager\Debug\RSP00000416012186844.rsp"
con contenido
[
/OUT:"D:\Ser teleco
mola\IPTV\Aplicación\Desarrollo\dIPTV\Debug\contents_manager.exe"
/INCREMENTAL /LIBPATH:"D:\Ser teleco
mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\lib" /MANIFEST
/MANIFESTFILE:"Debug\contents_manager.exe.intermediate.manifest"
/DEBUG /ASSEMBLYDEBUG /PDB:"d:\Ser teleco
mola\IPTV\Aplicación\Desarrollo\dIPTV\debug\contents_manager.pdb"
/SUBSYSTEM:CONSOLE /MACHINE:X86 /FIXED:No kernel32.lib

".\Debug\contents_manager.obj"
]
Creando línea de comandos "link.exe @"d:\Ser teleco
mola\IPTV\Aplicación\Desarrollo\dIPTV\contents_manager\Debug\RSP00000416012186844.rsp"
/NOLOGO /ERRORREPORT:PROMPT"



So it seems I have added properly the folder but it does not work. This
folder contains xerces_c_2.lib, xerces_c_2D.lib and static(2) and depdom (4)
extensions, 8 files.

I don't know if I need to configure anything more... I am so sorry, but can
you help me, please? I promise you that as soon as I can link properly I
will ask more "interesting" questions..haha.

Thank you a lot,
Javi


2007/11/29, Alberto Massari <am...@datadirect.com>:
>
> Javier,
> the same operation you did for the include folder should be done for the
> lib folder (using the Link property page of the Project properties if
> you want to fix just this project, or using the VC++ Directories
> property page in the Tools | Options menu, after selecting Library files
> in the combo box).
> In case you didn't already do it, you also need to list xerces_2.lib
> (for release builds) and xerces_2D.lib (for debug builds) in the
> 'additional libraries' entry of the project properties.
>
> Alberto
>
> Javier Gálvez Guerrero wrote:
> > I think that the attachement doesn't work properly, so I'll copy paste
> the
> > first outputs:
> >
> > Vinculando... contents_manager.obj : warning LNK4248: símbolo (token) de
> > typeref sin resolver (01000019) para 'xercesc_2_8.XMLValidator'; no se
> puede
> > ejecutar la imagen contents_manager.obj: warning LNK4248: símbolo
> (token) de
> > typeref sin resolver (0100001A) para 'xercesc_2_8.XMLGrammarPool'; no se
> > puede ejecutar la imagen contents_manager.obj : error LNK2028: se hace
> > referencia al símbolo (token) sin resolver (0A0003AE) "public: class
> > xercesc_2_8::DOMDocument * __thiscall
> > xercesc_2_8::AbstractDOMParser::getDocument(void)" (?getDocument@
> > AbstractDOMParser@xercesc_2_8@@$$FQAEPAVDOMDocument@2@XZ) en la función
> > "public: void __thiscall contents_manager::load_guide(class
> > std::basic_string,class std::allocator >)"
> > (?load_guide@contents_manager@@$$FQAEXV?$basic_string@DU?$char_traits@D
> > @std@@V?$allocator@D@2@@std@@@Z)
> >
> > Sorry for the inconvenience,
> > Javi
> >
> > 2007/11/28, Javier Gálvez Guerrero <du...@gmail.com>:
> >
> >> Should I configure anything for the linking files as I did with the
> >> Include?
> >>
> >> I have compiled my code with no errors, but at the time of linking
> appear
> >> lots of errors (BuildLog.htm attached).
> >>
> >> Thank you,
> >> Javi
> >>
> >> PS: Jesse, thanks a lot for your explanation about System.XML and its
> >> features. I am trying to design an application as multiplatform as
> possible
> >> and now that I have started with Xerces I would like to use it. But
> it's
> >> good to know all the alternatives out there. =).
> >>
> >>
> >>
> >> 2007/11/28, Jesse Pelton <js...@pkc.com>:
> >>
> >>> Regarding System.XML versus Xerces: Xerces exists to provide a solid,
> >>> open-source, cross-platform implementation of certain XML standards
> for C++
> >>> developers.  Almost all C++ developers are using unmanaged code; I
> think
> >>> you're the first I've heard of using Xerces with managed C++.
> >>>
> >>> To the extent that you're in a managed-code environment, Mono's
> >>> implementation of System.XML may fulfill the same requirements.  If
> >>> you're targeting Windows exclusively, the cross-platform issue is of
> no
> >>> consequence; you'll use the Microsoft implementation.  My
> understanding is
> >>> that System.XML is well-designed and robust, but I can't vouch for
> that
> >>> myself.  That leaves openness; if that's not important for your
> project,
> >>> System.XML would probably be at least as good a fit as Xerces (and I
> >>> imagine there's a large community of managed code developers who can
> help
> >>> you out, though not one of them is as good as Alberto).  Using
> >>> System.XML would avoid redundancy: you wouldn't have to distribute,
> and
> >>> your developers wouldn't have to understand, an additional library.
> >>>
> >>> This is not to say that you shouldn't use Xerces; it's a great
> >>> library.  Just know your options.
> >>>
> >>> -----Original Message-----
> >>> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
> >>> Sent: Wednesday, November 28, 2007 12:15 PM
> >>> To: c-users@xerces.apache.org
> >>> Subject: Re: How to parse using DOM
> >>>
> >>> Alberto,
> >>> Thanks again. Everything worked fine.
> >>>
> >>> By the way, as I use getNodeValue and getNodeName to process and
> assign
> >>> them
> >>> to my C++ structures I need to parse the XMLCh* returned value to
> >>> String^
> >>> buy I couldn't find any way to do it. Any idea?
> >>>
> >>> Jesse,
> >>> That's a good question..xD. There are many reasons why I am trying to
> >>> use
> >>> Xerces in order to parse and create XML files. Maybe you'll find them
> >>> stupid.
> >>>
> >>> Firstly, I am an absolute newbie with C++ as with Xerces (as you have
> >>> already realized). So, I did no research on XML classes offered by the
> >>> .NET
> >>> framework as I didn't know them.
> >>> Secondly, I am developing an application based on a previous version
> >>> which
> >>> was developed by another person, who based his app on Xerces to parse
> >>> XML
> >>> files. The problem is that his design didn't take into account
> creating
> >>> or
> >>> writing on XML files, only parsing and reading, so he used the SAX
> API.
> >>> Then, I had to switch from SAX to DOM and facing all the problems it
> >>> implies
> >>> (creating a NEW app).
> >>> Thirdly, I thought I could find some help if I based my design on a
> open
> >>> source solution like Xerces is, and here it is.
> >>>
> >>> Then, if you tell me that it is worth for me working with the
> System:XML
> >>> files, then I would think about it..haha. But then, what is Xerces for
> >>> if
> >>> everybody can manage their XML files with these classes?
> >>>
> >>> Cheers,
> >>> Javi
> >>>
> >>> 2007/11/28, Jesse Pelton <js...@pkc.com>:
> >>>
> >>>> Just out of curiosity, if you're using managed code, why aren't you
> >>>>
> >>> using
> >>>
> >>>> the System.XML classes?
> >>>>
> >>>> -----Original Message-----
> >>>> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
> >>>> Sent: Wednesday, November 28, 2007 11:03 AM
> >>>> To: c-users@xerces.apache.org
> >>>> Subject: Re: How to parse using DOM
> >>>>
> >>>> Hi there.
> >>>>
> >>>> Now I can compile the source code file where I have implemented (or
> >>>>
> >>> tried
> >>>
> >>>> it...) the DOM parser, some errors have appeared. As they seem quite
> >>>> simple
> >>>> I hope you could help me again:
> >>>>
> >>>> The method in file.cpp is like this (I have followed the guidelines
> >>>> < http://xerces.apache.org/xerces-c/program-dom.html>on Xerces site,
> >>>>
> >>> except
> >>>
> >>>> for the exception treatment...):
> >>>>
> >>>> void contents_manager::load_guide(String^ xml_path){
> >>>>
> >>>>     XMLPlatformUtils::Initialize();
> >>>>     XercesDOMParser* parser = new XercesDOMParser();
> >>>>
> >>>>     parser->parse(xml_path);
> >>>>     DOMNode* root = parser->getDocument(); //child_aux1 will be the
> >>>>
> >>> first
> >>>
> >>>> child of root
> >>>>     DOMNode* child_aux1, child_aux2, child_aux3, child_aux4,
> >>>>
> >>> child_aux5,
> >>>
> >>>> child_aux6, child_aux7; // Compiling errors referring to this line
> >>>>
> >>>>        //...
> >>>>
> >>>> In file.h this is included:
> >>>>
> >>>> #include "../include/gincludes.h"
> >>>> #include "../content/content.h"
> >>>> #include <xercesc/dom/DOM.hpp>
> >>>> #include <xercesc/dom/DOMImplementation.hpp>
> >>>> #include <xercesc/dom/DOMImplementationLS.hpp>
> >>>> #include <xercesc/dom/DOMWriter.hpp>
> >>>> #include <xercesc/util/PlatformUtils.hpp>
> >>>> #include <xercesc/parsers/XercesDOMParser.hpp>
> >>>> #include <xercesc/dom/DOM.hpp>
> >>>> #include <xercesc/util/XMLString.hpp>
> >>>> #include <xercesc/util/PlatformUtils.hpp>
> >>>>
> >>>> using namespace System;
> >>>>
> >>>> XERCES_CPP_NAMESPACE_USE
> >>>>
> >>>> // class definition...
> >>>>
> >>>> Then, when compiling a lot of errors appear saying that it can not be
> >>>>
> >>> done
> >>>
> >>>> as I am working with abstracts, referring to the previous red line...
> >>>>
> >>>> 1>.\contents_manager.cpp(17) : error C2259: xercesc_2_8::DOMNode' :
> no
> >>>>
> >>> se
> >>>
> >>>> puede crear una instancia de una clase abstract
> >>>> 1>        debido a los siguientes miembros:
> >>>> 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeName(void)
> const'
> >>>>
> >>> :
> >>>
> >>>> es
> >>>> abstracto
> >>>> 1>        D:\Ser teleco
> >>>>
> >>>>
> >>>>
> >>>
> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(246)
> >>>
> >>>> : vea la declaración de 'xercesc_2_8::DOMNode::getNodeName'
> >>>> 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeValue(void)
> >>>>
> >>> const' :
> >>>
> >>>> es
> >>>> abstracto
> >>>> 1>        D:\Ser teleco
> >>>>
> >>>>
> >>>>
> >>>
> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(255)
> >>>
> >>>> : vea la declaración de 'xercesc_2_8::DOMNode::getNodeValue'
> >>>> 1>        'short xercesc_2_8::DOMNode::getNodeType(void) const' : es
> >>>> abstracto
> >>>> ...
> >>>>
> >>>> Any idea of what I need to do regarding this error?
> >>>>
> >>>>
> >>>> By the way, as you may have seen on the arguments of my method, the
> >>>> name/path of the XML file is received with String^ type, so, as I
> need
> >>>>
> >>> to
> >>>
> >>>> have a char* as an argument for parse->parse(file_name), how can I
> >>>>
> >>> parse
> >>>
> >>>> it?
> >>>>
> >>>> Thank you very much,
> >>>>
> >>>> Javi
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> 2007/11/28, Sven Bauhan <sv...@ast.dfs.de>:
> >>>>
> >>>>>> This is not true.  std::string and UTF-8 are fully compatible, as
> >>>>>>
> >>> long
> >>>
> >>>>> as
> >>>>>
> >>>>>> you make no assumptions about chopping things up at arbitrary
> >>>>>>
> >>> indices,
> >>>
> >>>>> or
> >>>>>
> >>>>>> the relationship of Unicode code points and UTF-8 code units.  At
> >>>>>>
> >>> any
> >>>
> >>>>> rate,
> >>>>>
> >>>>>> with a double-byte or multi-byte locale code page, you'd have the
> >>>>>>
> >>> same
> >>>
> >>>>>> issues.
> >>>>>>
> >>>>>>
> >>>>> I do not really understand what you want to say here. As far as I
> >>>>>
> >>> know
> >>>
> >>>>> std::string stores strings in single byte units. In UTF-8 the units
> >>>>>
> >>> have
> >>>
> >>>>> variable length between 1 and 4 bytes. So I cannot see a match here.
> >>>>> I thought to use UTF-8 with the STL you need something like
> >>>>> std::basic_string<UTFChar>.
> >>>>>
> >>>>> Could you tell me, how to transcode the XMLChar* correctly using
> >>>>>
> >>> UTF-8?
> >>>
> >>>>> Sven
> >>>>>
> >>>>>
> >>
> >>
> >
> >
>
>

Re: How to parse using DOM

Posted by Alberto Massari <am...@datadirect.com>.
Javier,
the same operation you did for the include folder should be done for the 
lib folder (using the Link property page of the Project properties if 
you want to fix just this project, or using the VC++ Directories 
property page in the Tools | Options menu, after selecting Library files 
in the combo box).
In case you didn't already do it, you also need to list xerces_2.lib 
(for release builds) and xerces_2D.lib (for debug builds) in the 
'additional libraries' entry of the project properties.

Alberto

Javier Gálvez Guerrero wrote:
> I think that the attachement doesn't work properly, so I'll copy paste the
> first outputs:
>
> Vinculando... contents_manager.obj : warning LNK4248: símbolo (token) de
> typeref sin resolver (01000019) para 'xercesc_2_8.XMLValidator'; no se puede
> ejecutar la imagen contents_manager.obj: warning LNK4248: símbolo (token) de
> typeref sin resolver (0100001A) para 'xercesc_2_8.XMLGrammarPool'; no se
> puede ejecutar la imagen contents_manager.obj : error LNK2028: se hace
> referencia al símbolo (token) sin resolver (0A0003AE) "public: class
> xercesc_2_8::DOMDocument * __thiscall
> xercesc_2_8::AbstractDOMParser::getDocument(void)" (?getDocument@
> AbstractDOMParser@xercesc_2_8@@$$FQAEPAVDOMDocument@2@XZ) en la función
> "public: void __thiscall contents_manager::load_guide(class
> std::basic_string,class std::allocator >)"
> (?load_guide@contents_manager@@$$FQAEXV?$basic_string@DU?$char_traits@D
> @std@@V?$allocator@D@2@@std@@@Z)
>
> Sorry for the inconvenience,
> Javi
>
> 2007/11/28, Javier Gálvez Guerrero <du...@gmail.com>:
>   
>> Should I configure anything for the linking files as I did with the
>> Include?
>>
>> I have compiled my code with no errors, but at the time of linking appear
>> lots of errors (BuildLog.htm attached).
>>
>> Thank you,
>> Javi
>>
>> PS: Jesse, thanks a lot for your explanation about System.XML and its
>> features. I am trying to design an application as multiplatform as possible
>> and now that I have started with Xerces I would like to use it. But it's
>> good to know all the alternatives out there. =).
>>
>>
>>
>> 2007/11/28, Jesse Pelton <js...@pkc.com>:
>>     
>>> Regarding System.XML versus Xerces: Xerces exists to provide a solid,
>>> open-source, cross-platform implementation of certain XML standards for C++
>>> developers.  Almost all C++ developers are using unmanaged code; I think
>>> you're the first I've heard of using Xerces with managed C++.
>>>
>>> To the extent that you're in a managed-code environment, Mono's
>>> implementation of System.XML may fulfill the same requirements.  If
>>> you're targeting Windows exclusively, the cross-platform issue is of no
>>> consequence; you'll use the Microsoft implementation.  My understanding is
>>> that System.XML is well-designed and robust, but I can't vouch for that
>>> myself.  That leaves openness; if that's not important for your project,
>>> System.XML would probably be at least as good a fit as Xerces (and I
>>> imagine there's a large community of managed code developers who can help
>>> you out, though not one of them is as good as Alberto).  Using
>>> System.XML would avoid redundancy: you wouldn't have to distribute, and
>>> your developers wouldn't have to understand, an additional library.
>>>
>>> This is not to say that you shouldn't use Xerces; it's a great
>>> library.  Just know your options.
>>>
>>> -----Original Message-----
>>> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
>>> Sent: Wednesday, November 28, 2007 12:15 PM
>>> To: c-users@xerces.apache.org
>>> Subject: Re: How to parse using DOM
>>>
>>> Alberto,
>>> Thanks again. Everything worked fine.
>>>
>>> By the way, as I use getNodeValue and getNodeName to process and assign
>>> them
>>> to my C++ structures I need to parse the XMLCh* returned value to
>>> String^
>>> buy I couldn't find any way to do it. Any idea?
>>>
>>> Jesse,
>>> That's a good question..xD. There are many reasons why I am trying to
>>> use
>>> Xerces in order to parse and create XML files. Maybe you'll find them
>>> stupid.
>>>
>>> Firstly, I am an absolute newbie with C++ as with Xerces (as you have
>>> already realized). So, I did no research on XML classes offered by the
>>> .NET
>>> framework as I didn't know them.
>>> Secondly, I am developing an application based on a previous version
>>> which
>>> was developed by another person, who based his app on Xerces to parse
>>> XML
>>> files. The problem is that his design didn't take into account creating
>>> or
>>> writing on XML files, only parsing and reading, so he used the SAX API.
>>> Then, I had to switch from SAX to DOM and facing all the problems it
>>> implies
>>> (creating a NEW app).
>>> Thirdly, I thought I could find some help if I based my design on a open
>>> source solution like Xerces is, and here it is.
>>>
>>> Then, if you tell me that it is worth for me working with the System:XML
>>> files, then I would think about it..haha. But then, what is Xerces for
>>> if
>>> everybody can manage their XML files with these classes?
>>>
>>> Cheers,
>>> Javi
>>>
>>> 2007/11/28, Jesse Pelton <js...@pkc.com>:
>>>       
>>>> Just out of curiosity, if you're using managed code, why aren't you
>>>>         
>>> using
>>>       
>>>> the System.XML classes?
>>>>
>>>> -----Original Message-----
>>>> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
>>>> Sent: Wednesday, November 28, 2007 11:03 AM
>>>> To: c-users@xerces.apache.org
>>>> Subject: Re: How to parse using DOM
>>>>
>>>> Hi there.
>>>>
>>>> Now I can compile the source code file where I have implemented (or
>>>>         
>>> tried
>>>       
>>>> it...) the DOM parser, some errors have appeared. As they seem quite
>>>> simple
>>>> I hope you could help me again:
>>>>
>>>> The method in file.cpp is like this (I have followed the guidelines
>>>> < http://xerces.apache.org/xerces-c/program-dom.html>on Xerces site,
>>>>         
>>> except
>>>       
>>>> for the exception treatment...):
>>>>
>>>> void contents_manager::load_guide(String^ xml_path){
>>>>
>>>>     XMLPlatformUtils::Initialize();
>>>>     XercesDOMParser* parser = new XercesDOMParser();
>>>>
>>>>     parser->parse(xml_path);
>>>>     DOMNode* root = parser->getDocument(); //child_aux1 will be the
>>>>         
>>> first
>>>       
>>>> child of root
>>>>     DOMNode* child_aux1, child_aux2, child_aux3, child_aux4,
>>>>         
>>> child_aux5,
>>>       
>>>> child_aux6, child_aux7; // Compiling errors referring to this line
>>>>
>>>>        //...
>>>>
>>>> In file.h this is included:
>>>>
>>>> #include "../include/gincludes.h"
>>>> #include "../content/content.h"
>>>> #include <xercesc/dom/DOM.hpp>
>>>> #include <xercesc/dom/DOMImplementation.hpp>
>>>> #include <xercesc/dom/DOMImplementationLS.hpp>
>>>> #include <xercesc/dom/DOMWriter.hpp>
>>>> #include <xercesc/util/PlatformUtils.hpp>
>>>> #include <xercesc/parsers/XercesDOMParser.hpp>
>>>> #include <xercesc/dom/DOM.hpp>
>>>> #include <xercesc/util/XMLString.hpp>
>>>> #include <xercesc/util/PlatformUtils.hpp>
>>>>
>>>> using namespace System;
>>>>
>>>> XERCES_CPP_NAMESPACE_USE
>>>>
>>>> // class definition...
>>>>
>>>> Then, when compiling a lot of errors appear saying that it can not be
>>>>         
>>> done
>>>       
>>>> as I am working with abstracts, referring to the previous red line...
>>>>
>>>> 1>.\contents_manager.cpp(17) : error C2259: xercesc_2_8::DOMNode' : no
>>>>         
>>> se
>>>       
>>>> puede crear una instancia de una clase abstract
>>>> 1>        debido a los siguientes miembros:
>>>> 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeName(void) const'
>>>>         
>>> :
>>>       
>>>> es
>>>> abstracto
>>>> 1>        D:\Ser teleco
>>>>
>>>>
>>>>         
>>> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(246)
>>>       
>>>> : vea la declaración de 'xercesc_2_8::DOMNode::getNodeName'
>>>> 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeValue(void)
>>>>         
>>> const' :
>>>       
>>>> es
>>>> abstracto
>>>> 1>        D:\Ser teleco
>>>>
>>>>
>>>>         
>>> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(255)
>>>       
>>>> : vea la declaración de 'xercesc_2_8::DOMNode::getNodeValue'
>>>> 1>        'short xercesc_2_8::DOMNode::getNodeType(void) const' : es
>>>> abstracto
>>>> ...
>>>>
>>>> Any idea of what I need to do regarding this error?
>>>>
>>>>
>>>> By the way, as you may have seen on the arguments of my method, the
>>>> name/path of the XML file is received with String^ type, so, as I need
>>>>         
>>> to
>>>       
>>>> have a char* as an argument for parse->parse(file_name), how can I
>>>>         
>>> parse
>>>       
>>>> it?
>>>>
>>>> Thank you very much,
>>>>
>>>> Javi
>>>>
>>>>
>>>>
>>>>
>>>> 2007/11/28, Sven Bauhan <sv...@ast.dfs.de>:
>>>>         
>>>>>> This is not true.  std::string and UTF-8 are fully compatible, as
>>>>>>             
>>> long
>>>       
>>>>> as
>>>>>           
>>>>>> you make no assumptions about chopping things up at arbitrary
>>>>>>             
>>> indices,
>>>       
>>>>> or
>>>>>           
>>>>>> the relationship of Unicode code points and UTF-8 code units.  At
>>>>>>             
>>> any
>>>       
>>>>> rate,
>>>>>           
>>>>>> with a double-byte or multi-byte locale code page, you'd have the
>>>>>>             
>>> same
>>>       
>>>>>> issues.
>>>>>>
>>>>>>             
>>>>> I do not really understand what you want to say here. As far as I
>>>>>           
>>> know
>>>       
>>>>> std::string stores strings in single byte units. In UTF-8 the units
>>>>>           
>>> have
>>>       
>>>>> variable length between 1 and 4 bytes. So I cannot see a match here.
>>>>> I thought to use UTF-8 with the STL you need something like
>>>>> std::basic_string<UTFChar>.
>>>>>
>>>>> Could you tell me, how to transcode the XMLChar* correctly using
>>>>>           
>>> UTF-8?
>>>       
>>>>> Sven
>>>>>
>>>>>           
>>
>>     
>
>   


Re: How to parse using DOM

Posted by Javier Gálvez Guerrero <du...@gmail.com>.
I think that the attachement doesn't work properly, so I'll copy paste the
first outputs:

Vinculando... contents_manager.obj : warning LNK4248: símbolo (token) de
typeref sin resolver (01000019) para 'xercesc_2_8.XMLValidator'; no se puede
ejecutar la imagen contents_manager.obj: warning LNK4248: símbolo (token) de
typeref sin resolver (0100001A) para 'xercesc_2_8.XMLGrammarPool'; no se
puede ejecutar la imagen contents_manager.obj : error LNK2028: se hace
referencia al símbolo (token) sin resolver (0A0003AE) "public: class
xercesc_2_8::DOMDocument * __thiscall
xercesc_2_8::AbstractDOMParser::getDocument(void)" (?getDocument@
AbstractDOMParser@xercesc_2_8@@$$FQAEPAVDOMDocument@2@XZ) en la función
"public: void __thiscall contents_manager::load_guide(class
std::basic_string,class std::allocator >)"
(?load_guide@contents_manager@@$$FQAEXV?$basic_string@DU?$char_traits@D
@std@@V?$allocator@D@2@@std@@@Z)

Sorry for the inconvenience,
Javi

2007/11/28, Javier Gálvez Guerrero <du...@gmail.com>:
>
> Should I configure anything for the linking files as I did with the
> Include?
>
> I have compiled my code with no errors, but at the time of linking appear
> lots of errors (BuildLog.htm attached).
>
> Thank you,
> Javi
>
> PS: Jesse, thanks a lot for your explanation about System.XML and its
> features. I am trying to design an application as multiplatform as possible
> and now that I have started with Xerces I would like to use it. But it's
> good to know all the alternatives out there. =).
>
>
>
> 2007/11/28, Jesse Pelton <js...@pkc.com>:
> >
> > Regarding System.XML versus Xerces: Xerces exists to provide a solid,
> > open-source, cross-platform implementation of certain XML standards for C++
> > developers.  Almost all C++ developers are using unmanaged code; I think
> > you're the first I've heard of using Xerces with managed C++.
> >
> > To the extent that you're in a managed-code environment, Mono's
> > implementation of System.XML may fulfill the same requirements.  If
> > you're targeting Windows exclusively, the cross-platform issue is of no
> > consequence; you'll use the Microsoft implementation.  My understanding is
> > that System.XML is well-designed and robust, but I can't vouch for that
> > myself.  That leaves openness; if that's not important for your project,
> > System.XML would probably be at least as good a fit as Xerces (and I
> > imagine there's a large community of managed code developers who can help
> > you out, though not one of them is as good as Alberto).  Using
> > System.XML would avoid redundancy: you wouldn't have to distribute, and
> > your developers wouldn't have to understand, an additional library.
> >
> > This is not to say that you shouldn't use Xerces; it's a great
> > library.  Just know your options.
> >
> > -----Original Message-----
> > From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
> > Sent: Wednesday, November 28, 2007 12:15 PM
> > To: c-users@xerces.apache.org
> > Subject: Re: How to parse using DOM
> >
> > Alberto,
> > Thanks again. Everything worked fine.
> >
> > By the way, as I use getNodeValue and getNodeName to process and assign
> > them
> > to my C++ structures I need to parse the XMLCh* returned value to
> > String^
> > buy I couldn't find any way to do it. Any idea?
> >
> > Jesse,
> > That's a good question..xD. There are many reasons why I am trying to
> > use
> > Xerces in order to parse and create XML files. Maybe you'll find them
> > stupid.
> >
> > Firstly, I am an absolute newbie with C++ as with Xerces (as you have
> > already realized). So, I did no research on XML classes offered by the
> > .NET
> > framework as I didn't know them.
> > Secondly, I am developing an application based on a previous version
> > which
> > was developed by another person, who based his app on Xerces to parse
> > XML
> > files. The problem is that his design didn't take into account creating
> > or
> > writing on XML files, only parsing and reading, so he used the SAX API.
> > Then, I had to switch from SAX to DOM and facing all the problems it
> > implies
> > (creating a NEW app).
> > Thirdly, I thought I could find some help if I based my design on a open
> > source solution like Xerces is, and here it is.
> >
> > Then, if you tell me that it is worth for me working with the System:XML
> > files, then I would think about it..haha. But then, what is Xerces for
> > if
> > everybody can manage their XML files with these classes?
> >
> > Cheers,
> > Javi
> >
> > 2007/11/28, Jesse Pelton <js...@pkc.com>:
> > >
> > > Just out of curiosity, if you're using managed code, why aren't you
> > using
> > > the System.XML classes?
> > >
> > > -----Original Message-----
> > > From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
> > > Sent: Wednesday, November 28, 2007 11:03 AM
> > > To: c-users@xerces.apache.org
> > > Subject: Re: How to parse using DOM
> > >
> > > Hi there.
> > >
> > > Now I can compile the source code file where I have implemented (or
> > tried
> > > it...) the DOM parser, some errors have appeared. As they seem quite
> > > simple
> > > I hope you could help me again:
> > >
> > > The method in file.cpp is like this (I have followed the guidelines
> > > < http://xerces.apache.org/xerces-c/program-dom.html>on Xerces site,
> > except
> > > for the exception treatment...):
> > >
> > > void contents_manager::load_guide(String^ xml_path){
> > >
> > >     XMLPlatformUtils::Initialize();
> > >     XercesDOMParser* parser = new XercesDOMParser();
> > >
> > >     parser->parse(xml_path);
> > >     DOMNode* root = parser->getDocument(); //child_aux1 will be the
> > first
> > > child of root
> > >     DOMNode* child_aux1, child_aux2, child_aux3, child_aux4,
> > child_aux5,
> > > child_aux6, child_aux7; // Compiling errors referring to this line
> > >
> > >        //...
> > >
> > > In file.h this is included:
> > >
> > > #include "../include/gincludes.h"
> > > #include "../content/content.h"
> > > #include <xercesc/dom/DOM.hpp>
> > > #include <xercesc/dom/DOMImplementation.hpp>
> > > #include <xercesc/dom/DOMImplementationLS.hpp>
> > > #include <xercesc/dom/DOMWriter.hpp>
> > > #include <xercesc/util/PlatformUtils.hpp>
> > > #include <xercesc/parsers/XercesDOMParser.hpp>
> > > #include <xercesc/dom/DOM.hpp>
> > > #include <xercesc/util/XMLString.hpp>
> > > #include <xercesc/util/PlatformUtils.hpp>
> > >
> > > using namespace System;
> > >
> > > XERCES_CPP_NAMESPACE_USE
> > >
> > > // class definition...
> > >
> > > Then, when compiling a lot of errors appear saying that it can not be
> > done
> > > as I am working with abstracts, referring to the previous red line...
> > >
> > > 1>.\contents_manager.cpp(17) : error C2259: xercesc_2_8::DOMNode' : no
> > se
> > > puede crear una instancia de una clase abstract
> > > 1>        debido a los siguientes miembros:
> > > 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeName(void) const'
> > :
> > > es
> > > abstracto
> > > 1>        D:\Ser teleco
> > >
> > >
> > mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(246)
> > > : vea la declaración de 'xercesc_2_8::DOMNode::getNodeName'
> > > 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeValue(void)
> > const' :
> > > es
> > > abstracto
> > > 1>        D:\Ser teleco
> > >
> > >
> > mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(255)
> > > : vea la declaración de 'xercesc_2_8::DOMNode::getNodeValue'
> > > 1>        'short xercesc_2_8::DOMNode::getNodeType(void) const' : es
> > > abstracto
> > > ...
> > >
> > > Any idea of what I need to do regarding this error?
> > >
> > >
> > > By the way, as you may have seen on the arguments of my method, the
> > > name/path of the XML file is received with String^ type, so, as I need
> > to
> > > have a char* as an argument for parse->parse(file_name), how can I
> > parse
> > > it?
> > >
> > > Thank you very much,
> > >
> > > Javi
> > >
> > >
> > >
> > >
> > > 2007/11/28, Sven Bauhan <sv...@ast.dfs.de>:
> > > >
> > > > > This is not true.  std::string and UTF-8 are fully compatible, as
> > long
> > > > as
> > > > > you make no assumptions about chopping things up at arbitrary
> > indices,
> > > > or
> > > > > the relationship of Unicode code points and UTF-8 code units.  At
> > any
> > > > rate,
> > > > > with a double-byte or multi-byte locale code page, you'd have the
> > same
> > > > > issues.
> > > > >
> > > > I do not really understand what you want to say here. As far as I
> > know
> > > > std::string stores strings in single byte units. In UTF-8 the units
> > have
> > > > variable length between 1 and 4 bytes. So I cannot see a match here.
> > > > I thought to use UTF-8 with the STL you need something like
> > > > std::basic_string<UTFChar>.
> > > >
> > > > Could you tell me, how to transcode the XMLChar* correctly using
> > UTF-8?
> > > >
> > > > Sven
> > > >
> > >
> >
>
>
>

Re: How to parse using DOM

Posted by Javier Gálvez Guerrero <du...@gmail.com>.
Should I configure anything for the linking files as I did with the Include?


I have compiled my code with no errors, but at the time of linking appear
lots of errors (BuildLog.htm attached).

Thank you,
Javi

PS: Jesse, thanks a lot for your explanation about System.XML and its
features. I am trying to design an application as multiplatform as possible
and now that I have started with Xerces I would like to use it. But it's
good to know all the alternatives out there. =).



2007/11/28, Jesse Pelton <js...@pkc.com>:
>
> Regarding System.XML versus Xerces: Xerces exists to provide a solid,
> open-source, cross-platform implementation of certain XML standards for C++
> developers.  Almost all C++ developers are using unmanaged code; I think
> you're the first I've heard of using Xerces with managed C++.
>
> To the extent that you're in a managed-code environment, Mono's
> implementation of System.XML may fulfill the same requirements.  If you're
> targeting Windows exclusively, the cross-platform issue is of no
> consequence; you'll use the Microsoft implementation.  My understanding is
> that System.XML is well-designed and robust, but I can't vouch for that
> myself.  That leaves openness; if that's not important for your project,
> System.XML would probably be at least as good a fit as Xerces (and I
> imagine there's a large community of managed code developers who can help
> you out, though not one of them is as good as Alberto).  Using System.XMLwould avoid redundancy: you wouldn't have to distribute, and your developers
> wouldn't have to understand, an additional library.
>
> This is not to say that you shouldn't use Xerces; it's a great
> library.  Just know your options.
>
> -----Original Message-----
> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
> Sent: Wednesday, November 28, 2007 12:15 PM
> To: c-users@xerces.apache.org
> Subject: Re: How to parse using DOM
>
> Alberto,
> Thanks again. Everything worked fine.
>
> By the way, as I use getNodeValue and getNodeName to process and assign
> them
> to my C++ structures I need to parse the XMLCh* returned value to String^
> buy I couldn't find any way to do it. Any idea?
>
> Jesse,
> That's a good question..xD. There are many reasons why I am trying to use
> Xerces in order to parse and create XML files. Maybe you'll find them
> stupid.
>
> Firstly, I am an absolute newbie with C++ as with Xerces (as you have
> already realized). So, I did no research on XML classes offered by the
> .NET
> framework as I didn't know them.
> Secondly, I am developing an application based on a previous version which
> was developed by another person, who based his app on Xerces to parse XML
> files. The problem is that his design didn't take into account creating or
> writing on XML files, only parsing and reading, so he used the SAX API.
> Then, I had to switch from SAX to DOM and facing all the problems it
> implies
> (creating a NEW app).
> Thirdly, I thought I could find some help if I based my design on a open
> source solution like Xerces is, and here it is.
>
> Then, if you tell me that it is worth for me working with the System:XML
> files, then I would think about it..haha. But then, what is Xerces for if
> everybody can manage their XML files with these classes?
>
> Cheers,
> Javi
>
> 2007/11/28, Jesse Pelton <js...@pkc.com>:
> >
> > Just out of curiosity, if you're using managed code, why aren't you
> using
> > the System.XML classes?
> >
> > -----Original Message-----
> > From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
> > Sent: Wednesday, November 28, 2007 11:03 AM
> > To: c-users@xerces.apache.org
> > Subject: Re: How to parse using DOM
> >
> > Hi there.
> >
> > Now I can compile the source code file where I have implemented (or
> tried
> > it...) the DOM parser, some errors have appeared. As they seem quite
> > simple
> > I hope you could help me again:
> >
> > The method in file.cpp is like this (I have followed the guidelines
> > <http://xerces.apache.org/xerces-c/program-dom.html>on Xerces site,
> except
> > for the exception treatment...):
> >
> > void contents_manager::load_guide(String^ xml_path){
> >
> >     XMLPlatformUtils::Initialize();
> >     XercesDOMParser* parser = new XercesDOMParser();
> >
> >     parser->parse(xml_path);
> >     DOMNode* root = parser->getDocument(); //child_aux1 will be the
> first
> > child of root
> >     DOMNode* child_aux1, child_aux2, child_aux3, child_aux4, child_aux5,
> > child_aux6, child_aux7; // Compiling errors referring to this line
> >
> >        //...
> >
> > In file.h this is included:
> >
> > #include "../include/gincludes.h"
> > #include "../content/content.h"
> > #include <xercesc/dom/DOM.hpp>
> > #include <xercesc/dom/DOMImplementation.hpp>
> > #include <xercesc/dom/DOMImplementationLS.hpp>
> > #include <xercesc/dom/DOMWriter.hpp>
> > #include <xercesc/util/PlatformUtils.hpp>
> > #include <xercesc/parsers/XercesDOMParser.hpp>
> > #include <xercesc/dom/DOM.hpp>
> > #include <xercesc/util/XMLString.hpp>
> > #include <xercesc/util/PlatformUtils.hpp>
> >
> > using namespace System;
> >
> > XERCES_CPP_NAMESPACE_USE
> >
> > // class definition...
> >
> > Then, when compiling a lot of errors appear saying that it can not be
> done
> > as I am working with abstracts, referring to the previous red line...
> >
> > 1>.\contents_manager.cpp(17) : error C2259: xercesc_2_8::DOMNode' : no
> se
> > puede crear una instancia de una clase abstract
> > 1>        debido a los siguientes miembros:
> > 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeName(void) const' :
> > es
> > abstracto
> > 1>        D:\Ser teleco
> >
> >
> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(246)
> > : vea la declaración de 'xercesc_2_8::DOMNode::getNodeName'
> > 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeValue(void) const'
> :
> > es
> > abstracto
> > 1>        D:\Ser teleco
> >
> >
> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(255)
> > : vea la declaración de 'xercesc_2_8::DOMNode::getNodeValue'
> > 1>        'short xercesc_2_8::DOMNode::getNodeType(void) const' : es
> > abstracto
> > ...
> >
> > Any idea of what I need to do regarding this error?
> >
> >
> > By the way, as you may have seen on the arguments of my method, the
> > name/path of the XML file is received with String^ type, so, as I need
> to
> > have a char* as an argument for parse->parse(file_name), how can I parse
> > it?
> >
> > Thank you very much,
> >
> > Javi
> >
> >
> >
> >
> > 2007/11/28, Sven Bauhan <sv...@ast.dfs.de>:
> > >
> > > > This is not true.  std::string and UTF-8 are fully compatible, as
> long
> > > as
> > > > you make no assumptions about chopping things up at arbitrary
> indices,
> > > or
> > > > the relationship of Unicode code points and UTF-8 code units.  At
> any
> > > rate,
> > > > with a double-byte or multi-byte locale code page, you'd have the
> same
> > > > issues.
> > > >
> > > I do not really understand what you want to say here. As far as I know
> > > std::string stores strings in single byte units. In UTF-8 the units
> have
> > > variable length between 1 and 4 bytes. So I cannot see a match here.
> > > I thought to use UTF-8 with the STL you need something like
> > > std::basic_string<UTFChar>.
> > >
> > > Could you tell me, how to transcode the XMLChar* correctly using
> UTF-8?
> > >
> > > Sven
> > >
> >
>

RE: How to parse using DOM

Posted by Jesse Pelton <js...@PKC.com>.
Regarding System.XML versus Xerces: Xerces exists to provide a solid, open-source, cross-platform implementation of certain XML standards for C++ developers.  Almost all C++ developers are using unmanaged code; I think you're the first I've heard of using Xerces with managed C++.

To the extent that you're in a managed-code environment, Mono's implementation of System.XML may fulfill the same requirements.  If you're targeting Windows exclusively, the cross-platform issue is of no consequence; you'll use the Microsoft implementation.  My understanding is that System.XML is well-designed and robust, but I can't vouch for that myself.  That leaves openness; if that's not important for your project, System.XML would probably be at least as good a fit as Xerces (and I imagine there's a large community of managed code developers who can help you out, though not one of them is as good as Alberto).  Using System.XML would avoid redundancy: you wouldn't have to distribute, and your developers wouldn't have to understand, an additional library.

This is not to say that you shouldn't use Xerces; it's a great library.  Just know your options.

-----Original Message-----
From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com] 
Sent: Wednesday, November 28, 2007 12:15 PM
To: c-users@xerces.apache.org
Subject: Re: How to parse using DOM

Alberto,
Thanks again. Everything worked fine.

By the way, as I use getNodeValue and getNodeName to process and assign them
to my C++ structures I need to parse the XMLCh* returned value to String^
buy I couldn't find any way to do it. Any idea?

Jesse,
That's a good question..xD. There are many reasons why I am trying to use
Xerces in order to parse and create XML files. Maybe you'll find them
stupid.

Firstly, I am an absolute newbie with C++ as with Xerces (as you have
already realized). So, I did no research on XML classes offered by the .NET
framework as I didn't know them.
Secondly, I am developing an application based on a previous version which
was developed by another person, who based his app on Xerces to parse XML
files. The problem is that his design didn't take into account creating or
writing on XML files, only parsing and reading, so he used the SAX API.
Then, I had to switch from SAX to DOM and facing all the problems it implies
(creating a NEW app).
Thirdly, I thought I could find some help if I based my design on a open
source solution like Xerces is, and here it is.

Then, if you tell me that it is worth for me working with the System:XML
files, then I would think about it..haha. But then, what is Xerces for if
everybody can manage their XML files with these classes?

Cheers,
Javi

2007/11/28, Jesse Pelton <js...@pkc.com>:
>
> Just out of curiosity, if you're using managed code, why aren't you using
> the System.XML classes?
>
> -----Original Message-----
> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
> Sent: Wednesday, November 28, 2007 11:03 AM
> To: c-users@xerces.apache.org
> Subject: Re: How to parse using DOM
>
> Hi there.
>
> Now I can compile the source code file where I have implemented (or tried
> it...) the DOM parser, some errors have appeared. As they seem quite
> simple
> I hope you could help me again:
>
> The method in file.cpp is like this (I have followed the guidelines
> <http://xerces.apache.org/xerces-c/program-dom.html>on Xerces site, except
> for the exception treatment...):
>
> void contents_manager::load_guide(String^ xml_path){
>
>     XMLPlatformUtils::Initialize();
>     XercesDOMParser* parser = new XercesDOMParser();
>
>     parser->parse(xml_path);
>     DOMNode* root = parser->getDocument(); //child_aux1 will be the first
> child of root
>     DOMNode* child_aux1, child_aux2, child_aux3, child_aux4, child_aux5,
> child_aux6, child_aux7; // Compiling errors referring to this line
>
>        //...
>
> In file.h this is included:
>
> #include "../include/gincludes.h"
> #include "../content/content.h"
> #include <xercesc/dom/DOM.hpp>
> #include <xercesc/dom/DOMImplementation.hpp>
> #include <xercesc/dom/DOMImplementationLS.hpp>
> #include <xercesc/dom/DOMWriter.hpp>
> #include <xercesc/util/PlatformUtils.hpp>
> #include <xercesc/parsers/XercesDOMParser.hpp>
> #include <xercesc/dom/DOM.hpp>
> #include <xercesc/util/XMLString.hpp>
> #include <xercesc/util/PlatformUtils.hpp>
>
> using namespace System;
>
> XERCES_CPP_NAMESPACE_USE
>
> // class definition...
>
> Then, when compiling a lot of errors appear saying that it can not be done
> as I am working with abstracts, referring to the previous red line...
>
> 1>.\contents_manager.cpp(17) : error C2259: xercesc_2_8::DOMNode' : no se
> puede crear una instancia de una clase abstract
> 1>        debido a los siguientes miembros:
> 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeName(void) const' :
> es
> abstracto
> 1>        D:\Ser teleco
>
> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(246)
> : vea la declaración de 'xercesc_2_8::DOMNode::getNodeName'
> 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeValue(void) const' :
> es
> abstracto
> 1>        D:\Ser teleco
>
> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(255)
> : vea la declaración de 'xercesc_2_8::DOMNode::getNodeValue'
> 1>        'short xercesc_2_8::DOMNode::getNodeType(void) const' : es
> abstracto
> ...
>
> Any idea of what I need to do regarding this error?
>
>
> By the way, as you may have seen on the arguments of my method, the
> name/path of the XML file is received with String^ type, so, as I need to
> have a char* as an argument for parse->parse(file_name), how can I parse
> it?
>
> Thank you very much,
>
> Javi
>
>
>
>
> 2007/11/28, Sven Bauhan <sv...@ast.dfs.de>:
> >
> > > This is not true.  std::string and UTF-8 are fully compatible, as long
> > as
> > > you make no assumptions about chopping things up at arbitrary indices,
> > or
> > > the relationship of Unicode code points and UTF-8 code units.  At any
> > rate,
> > > with a double-byte or multi-byte locale code page, you'd have the same
> > > issues.
> > >
> > I do not really understand what you want to say here. As far as I know
> > std::string stores strings in single byte units. In UTF-8 the units have
> > variable length between 1 and 4 bytes. So I cannot see a match here.
> > I thought to use UTF-8 with the STL you need something like
> > std::basic_string<UTFChar>.
> >
> > Could you tell me, how to transcode the XMLChar* correctly using UTF-8?
> >
> > Sven
> >
>

Re: How to parse using DOM

Posted by Javier Gálvez Guerrero <du...@gmail.com>.
Alberto,
Thanks again. Everything worked fine.

By the way, as I use getNodeValue and getNodeName to process and assign them
to my C++ structures I need to parse the XMLCh* returned value to String^
buy I couldn't find any way to do it. Any idea?

Jesse,
That's a good question..xD. There are many reasons why I am trying to use
Xerces in order to parse and create XML files. Maybe you'll find them
stupid.

Firstly, I am an absolute newbie with C++ as with Xerces (as you have
already realized). So, I did no research on XML classes offered by the .NET
framework as I didn't know them.
Secondly, I am developing an application based on a previous version which
was developed by another person, who based his app on Xerces to parse XML
files. The problem is that his design didn't take into account creating or
writing on XML files, only parsing and reading, so he used the SAX API.
Then, I had to switch from SAX to DOM and facing all the problems it implies
(creating a NEW app).
Thirdly, I thought I could find some help if I based my design on a open
source solution like Xerces is, and here it is.

Then, if you tell me that it is worth for me working with the System:XML
files, then I would think about it..haha. But then, what is Xerces for if
everybody can manage their XML files with these classes?

Cheers,
Javi

2007/11/28, Jesse Pelton <js...@pkc.com>:
>
> Just out of curiosity, if you're using managed code, why aren't you using
> the System.XML classes?
>
> -----Original Message-----
> From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com]
> Sent: Wednesday, November 28, 2007 11:03 AM
> To: c-users@xerces.apache.org
> Subject: Re: How to parse using DOM
>
> Hi there.
>
> Now I can compile the source code file where I have implemented (or tried
> it...) the DOM parser, some errors have appeared. As they seem quite
> simple
> I hope you could help me again:
>
> The method in file.cpp is like this (I have followed the guidelines
> <http://xerces.apache.org/xerces-c/program-dom.html>on Xerces site, except
> for the exception treatment...):
>
> void contents_manager::load_guide(String^ xml_path){
>
>     XMLPlatformUtils::Initialize();
>     XercesDOMParser* parser = new XercesDOMParser();
>
>     parser->parse(xml_path);
>     DOMNode* root = parser->getDocument(); //child_aux1 will be the first
> child of root
>     DOMNode* child_aux1, child_aux2, child_aux3, child_aux4, child_aux5,
> child_aux6, child_aux7; // Compiling errors referring to this line
>
>        //...
>
> In file.h this is included:
>
> #include "../include/gincludes.h"
> #include "../content/content.h"
> #include <xercesc/dom/DOM.hpp>
> #include <xercesc/dom/DOMImplementation.hpp>
> #include <xercesc/dom/DOMImplementationLS.hpp>
> #include <xercesc/dom/DOMWriter.hpp>
> #include <xercesc/util/PlatformUtils.hpp>
> #include <xercesc/parsers/XercesDOMParser.hpp>
> #include <xercesc/dom/DOM.hpp>
> #include <xercesc/util/XMLString.hpp>
> #include <xercesc/util/PlatformUtils.hpp>
>
> using namespace System;
>
> XERCES_CPP_NAMESPACE_USE
>
> // class definition...
>
> Then, when compiling a lot of errors appear saying that it can not be done
> as I am working with abstracts, referring to the previous red line...
>
> 1>.\contents_manager.cpp(17) : error C2259: xercesc_2_8::DOMNode' : no se
> puede crear una instancia de una clase abstract
> 1>        debido a los siguientes miembros:
> 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeName(void) const' :
> es
> abstracto
> 1>        D:\Ser teleco
>
> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(246)
> : vea la declaración de 'xercesc_2_8::DOMNode::getNodeName'
> 1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeValue(void) const' :
> es
> abstracto
> 1>        D:\Ser teleco
>
> mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(255)
> : vea la declaración de 'xercesc_2_8::DOMNode::getNodeValue'
> 1>        'short xercesc_2_8::DOMNode::getNodeType(void) const' : es
> abstracto
> ...
>
> Any idea of what I need to do regarding this error?
>
>
> By the way, as you may have seen on the arguments of my method, the
> name/path of the XML file is received with String^ type, so, as I need to
> have a char* as an argument for parse->parse(file_name), how can I parse
> it?
>
> Thank you very much,
>
> Javi
>
>
>
>
> 2007/11/28, Sven Bauhan <sv...@ast.dfs.de>:
> >
> > > This is not true.  std::string and UTF-8 are fully compatible, as long
> > as
> > > you make no assumptions about chopping things up at arbitrary indices,
> > or
> > > the relationship of Unicode code points and UTF-8 code units.  At any
> > rate,
> > > with a double-byte or multi-byte locale code page, you'd have the same
> > > issues.
> > >
> > I do not really understand what you want to say here. As far as I know
> > std::string stores strings in single byte units. In UTF-8 the units have
> > variable length between 1 and 4 bytes. So I cannot see a match here.
> > I thought to use UTF-8 with the STL you need something like
> > std::basic_string<UTFChar>.
> >
> > Could you tell me, how to transcode the XMLChar* correctly using UTF-8?
> >
> > Sven
> >
>

RE: How to parse using DOM

Posted by Jesse Pelton <js...@PKC.com>.
Just out of curiosity, if you're using managed code, why aren't you using the System.XML classes? 

-----Original Message-----
From: Javier Gálvez Guerrero [mailto:dulceangustia@gmail.com] 
Sent: Wednesday, November 28, 2007 11:03 AM
To: c-users@xerces.apache.org
Subject: Re: How to parse using DOM

Hi there.

Now I can compile the source code file where I have implemented (or tried
it...) the DOM parser, some errors have appeared. As they seem quite simple
I hope you could help me again:

The method in file.cpp is like this (I have followed the guidelines
<http://xerces.apache.org/xerces-c/program-dom.html>on Xerces site, except
for the exception treatment...):

void contents_manager::load_guide(String^ xml_path){

    XMLPlatformUtils::Initialize();
    XercesDOMParser* parser = new XercesDOMParser();

    parser->parse(xml_path);
    DOMNode* root = parser->getDocument(); //child_aux1 will be the first
child of root
    DOMNode* child_aux1, child_aux2, child_aux3, child_aux4, child_aux5,
child_aux6, child_aux7; // Compiling errors referring to this line

       //...

In file.h this is included:

#include "../include/gincludes.h"
#include "../content/content.h"
#include <xercesc/dom/DOM.hpp>
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMImplementationLS.hpp>
#include <xercesc/dom/DOMWriter.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>

using namespace System;

XERCES_CPP_NAMESPACE_USE

// class definition...

Then, when compiling a lot of errors appear saying that it can not be done
as I am working with abstracts, referring to the previous red line...

1>.\contents_manager.cpp(17) : error C2259: xercesc_2_8::DOMNode' : no se
puede crear una instancia de una clase abstract
1>        debido a los siguientes miembros:
1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeName(void) const' : es
abstracto
1>        D:\Ser teleco
mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(246)
: vea la declaración de 'xercesc_2_8::DOMNode::getNodeName'
1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeValue(void) const' : es
abstracto
1>        D:\Ser teleco
mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(255)
: vea la declaración de 'xercesc_2_8::DOMNode::getNodeValue'
1>        'short xercesc_2_8::DOMNode::getNodeType(void) const' : es
abstracto
...

Any idea of what I need to do regarding this error?


By the way, as you may have seen on the arguments of my method, the
name/path of the XML file is received with String^ type, so, as I need to
have a char* as an argument for parse->parse(file_name), how can I parse it?

Thank you very much,

Javi




2007/11/28, Sven Bauhan <sv...@ast.dfs.de>:
>
> > This is not true.  std::string and UTF-8 are fully compatible, as long
> as
> > you make no assumptions about chopping things up at arbitrary indices,
> or
> > the relationship of Unicode code points and UTF-8 code units.  At any
> rate,
> > with a double-byte or multi-byte locale code page, you'd have the same
> > issues.
> >
> I do not really understand what you want to say here. As far as I know
> std::string stores strings in single byte units. In UTF-8 the units have
> variable length between 1 and 4 bytes. So I cannot see a match here.
> I thought to use UTF-8 with the STL you need something like
> std::basic_string<UTFChar>.
>
> Could you tell me, how to transcode the XMLChar* correctly using UTF-8?
>
> Sven
>

Re: How to parse using DOM

Posted by Alberto Massari <am...@datadirect.com>.
Hi Javier,

Javier Gálvez Guerrero wrote:
> Hi there.
>
> Now I can compile the source code file where I have implemented (or tried
> it...) the DOM parser, some errors have appeared. As they seem quite simple
> I hope you could help me again:
>
> The method in file.cpp is like this (I have followed the guidelines
> <http://xerces.apache.org/xerces-c/program-dom.html>on Xerces site, except
> for the exception treatment...):
>
> void contents_manager::load_guide(String^ xml_path){
>
>     XMLPlatformUtils::Initialize();
>     XercesDOMParser* parser = new XercesDOMParser();
>
>     parser->parse(xml_path);
>     DOMNode* root = parser->getDocument(); //child_aux1 will be the first
> child of root
>     DOMNode* child_aux1, child_aux2, child_aux3, child_aux4, child_aux5,
> child_aux6, child_aux7; // Compiling errors referring to this line
>
>   
You are missing the '*' for the variables after child_aux1; the correct 
declaration is

  DOMNode* child_aux1, *child_aux2, *child_aux3, *child_aux4, *child_aux5, *child_aux6, *child_aux7;


> [..]
>
>
> By the way, as you may have seen on the arguments of my method, the
> name/path of the XML file is received with String^ type, so, as I need to
> have a char* as an argument for parse->parse(file_name), how can I parse it?
>   
See http://support.microsoft.com/kb/311259

Alberto

>
>
>
> 2007/11/28, Sven Bauhan <sv...@ast.dfs.de>:
>   
>>> This is not true.  std::string and UTF-8 are fully compatible, as long
>>>       
>> as
>>     
>>> you make no assumptions about chopping things up at arbitrary indices,
>>>       
>> or
>>     
>>> the relationship of Unicode code points and UTF-8 code units.  At any
>>>       
>> rate,
>>     
>>> with a double-byte or multi-byte locale code page, you'd have the same
>>> issues.
>>>
>>>       
>> I do not really understand what you want to say here. As far as I know
>> std::string stores strings in single byte units. In UTF-8 the units have
>> variable length between 1 and 4 bytes. So I cannot see a match here.
>> I thought to use UTF-8 with the STL you need something like
>> std::basic_string<UTFChar>.
>>
>> Could you tell me, how to transcode the XMLChar* correctly using UTF-8?
>>
>> Sven
>>
>>     
>
>   


Re: How to parse using DOM

Posted by Javier Gálvez Guerrero <du...@gmail.com>.
Hi there.

Now I can compile the source code file where I have implemented (or tried
it...) the DOM parser, some errors have appeared. As they seem quite simple
I hope you could help me again:

The method in file.cpp is like this (I have followed the guidelines
<http://xerces.apache.org/xerces-c/program-dom.html>on Xerces site, except
for the exception treatment...):

void contents_manager::load_guide(String^ xml_path){

    XMLPlatformUtils::Initialize();
    XercesDOMParser* parser = new XercesDOMParser();

    parser->parse(xml_path);
    DOMNode* root = parser->getDocument(); //child_aux1 will be the first
child of root
    DOMNode* child_aux1, child_aux2, child_aux3, child_aux4, child_aux5,
child_aux6, child_aux7; // Compiling errors referring to this line

       //...

In file.h this is included:

#include "../include/gincludes.h"
#include "../content/content.h"
#include <xercesc/dom/DOM.hpp>
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMImplementationLS.hpp>
#include <xercesc/dom/DOMWriter.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>

using namespace System;

XERCES_CPP_NAMESPACE_USE

// class definition...

Then, when compiling a lot of errors appear saying that it can not be done
as I am working with abstracts, referring to the previous red line...

1>.\contents_manager.cpp(17) : error C2259: xercesc_2_8::DOMNode' : no se
puede crear una instancia de una clase abstract
1>        debido a los siguientes miembros:
1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeName(void) const' : es
abstracto
1>        D:\Ser teleco
mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(246)
: vea la declaración de 'xercesc_2_8::DOMNode::getNodeName'
1>        'const XMLCh *xercesc_2_8::DOMNode::getNodeValue(void) const' : es
abstracto
1>        D:\Ser teleco
mola\IPTV\Aplicación\Desarrollo\dIPTV\xercesc_2_8_0\include\xercesc/dom/DOMNode.hpp(255)
: vea la declaración de 'xercesc_2_8::DOMNode::getNodeValue'
1>        'short xercesc_2_8::DOMNode::getNodeType(void) const' : es
abstracto
...

Any idea of what I need to do regarding this error?


By the way, as you may have seen on the arguments of my method, the
name/path of the XML file is received with String^ type, so, as I need to
have a char* as an argument for parse->parse(file_name), how can I parse it?

Thank you very much,

Javi




2007/11/28, Sven Bauhan <sv...@ast.dfs.de>:
>
> > This is not true.  std::string and UTF-8 are fully compatible, as long
> as
> > you make no assumptions about chopping things up at arbitrary indices,
> or
> > the relationship of Unicode code points and UTF-8 code units.  At any
> rate,
> > with a double-byte or multi-byte locale code page, you'd have the same
> > issues.
> >
> I do not really understand what you want to say here. As far as I know
> std::string stores strings in single byte units. In UTF-8 the units have
> variable length between 1 and 4 bytes. So I cannot see a match here.
> I thought to use UTF-8 with the STL you need something like
> std::basic_string<UTFChar>.
>
> Could you tell me, how to transcode the XMLChar* correctly using UTF-8?
>
> Sven
>

Re: How to parse using DOM

Posted by David Bertoni <db...@apache.org>.
Sven Bauhan wrote:
>> This is not true.  std::string and UTF-8 are fully compatible, as long as
>> you make no assumptions about chopping things up at arbitrary indices, or
>> the relationship of Unicode code points and UTF-8 code units.  At any rate,
>> with a double-byte or multi-byte locale code page, you'd have the same
>> issues.
>>
> I do not really understand what you want to say here. As far as I know 
> std::string stores strings in single byte units. In UTF-8 the units have 
> variable length between 1 and 4 bytes. So I cannot see a match here.
> I thought to use UTF-8 with the STL you need something like 
> std::basic_string<UTFChar>.
You are confusing code points and code units.  The size of a code unit in 
UTF-8 is an octet (8 bits, or one byte on most architectures).  The number 
of octets required to encode a particular Unicode code point in UTF-8 is 1, 
2, 3, or 4.  If you ignore architectures where a byte stores more than 8 
bits, you can then assume that an octet and a byte are interchangeable.

UTF-8 was designed to be compatible with the char data type, and 
null-terminated arrays of UTF-8 code units are compatible with many C/C++ 
runtime functions that accept C-style strings.  The problems start when you 
rely on locale-specific behavior, or you make assumptions about the 
relationship of code points and code units.  For example, a substring 
operation could be problematic if I split a multi-byte UTF-8 sequence. 
Another example is code that relies on functions like isdigit, which are 
sensitive to the locale and/or the system default encoding for char.  In 
that case, UTF-8 bytes might be mistakenly interpreted as code points in 
the system encoding.

> 
> Could you tell me, how to transcode the XMLChar* correctly using UTF-8?
You call the transcoding service and create a UTF-8 transcoder.  There is a 
code snippet in another thread that's on-going, with the subject 
"Converting XMLCh* to std::string with encoding."

Dave

Re: How to parse using DOM

Posted by Sven Bauhan <sv...@ast.dfs.de>.
> This is not true.  std::string and UTF-8 are fully compatible, as long as
> you make no assumptions about chopping things up at arbitrary indices, or
> the relationship of Unicode code points and UTF-8 code units.  At any rate,
> with a double-byte or multi-byte locale code page, you'd have the same
> issues.
>
I do not really understand what you want to say here. As far as I know 
std::string stores strings in single byte units. In UTF-8 the units have 
variable length between 1 and 4 bytes. So I cannot see a match here.
I thought to use UTF-8 with the STL you need something like 
std::basic_string<UTFChar>.

Could you tell me, how to transcode the XMLChar* correctly using UTF-8?

Sven

Re: How to parse using DOM

Posted by David Bertoni <db...@apache.org>.
Sven Bauhan wrote:
>> Your class uses XMLString::transcode(), which transcodes to the local code
>> page.  This will result in data loss in cases where content contains
>> Unicode characters that are not representable in the local code page.  A
>> better choice would be to transcode to UTF-8, which is compatible with
>> char* APIs, and has the advantage that it can represent any Unicode
>> character.
>>
> I also found this not quite good, but I could not find out how to convert to 
> UTF-8. Perhaps you could provide an example?
> 
> Anyhow std::string is not capable handling UTF-8 - so the data has to be 
> transcoded using the local code page when using std::string.
This is not true.  std::string and UTF-8 are fully compatible, as long as 
you make no assumptions about chopping things up at arbitrary indices, or 
the relationship of Unicode code points and UTF-8 code units.  At any rate, 
with a double-byte or multi-byte locale code page, you'd have the same issues.

Dave

Re: How to parse using DOM

Posted by Sven Bauhan <sv...@ast.dfs.de>.
> Your class uses XMLString::transcode(), which transcodes to the local code
> page.  This will result in data loss in cases where content contains
> Unicode characters that are not representable in the local code page.  A
> better choice would be to transcode to UTF-8, which is compatible with
> char* APIs, and has the advantage that it can represent any Unicode
> character.
>
I also found this not quite good, but I could not find out how to convert to 
UTF-8. Perhaps you could provide an example?

Anyhow std::string is not capable handling UTF-8 - so the data has to be 
transcoded using the local code page when using std::string.

Sven

Re: How to parse using DOM

Posted by David Bertoni <db...@apache.org>.
Sven Bauhan wrote:
> Hi Javi,
> 
> the Xerces interface is not really intuitively. A short description can be 
> found at the DOM programming giude: 
> http://xerces.apache.org/xerces-c/program.html
> 
> In the Xerces documentation it is often described to use an extra class for 
> the conversion of std::string and XMLChar*. I have written such a class. As 
> it is quite short, I attach it here.
Your class uses XMLString::transcode(), which transcodes to the local code 
page.  This will result in data loss in cases where content contains 
Unicode characters that are not representable in the local code page.  A 
better choice would be to transcode to UTF-8, which is compatible with 
char* APIs, and has the advantage that it can represent any Unicode character.

There are many postings in the archives that will illustrate why using 
XMLString::transcode() is a bad idea.  I wish we would actually modify the 
analogous class in our samples so it doesn't do local code page 
transcoding, as it's providing a bad example.

Dave

Re: How to parse using DOM

Posted by Sven Bauhan <sv...@ast.dfs.de>.
Hi Javi,

the Xerces interface is not really intuitively. A short description can be 
found at the DOM programming giude: 
http://xerces.apache.org/xerces-c/program.html

In the Xerces documentation it is often described to use an extra class for 
the conversion of std::string and XMLChar*. I have written such a class. As 
it is quite short, I attach it here.

Sven

Re: How to parse using DOM

Posted by Alberto Massari <am...@datadirect.com>.
Hi Javier,
have a look at the DOMPrint sample; it shows how to create a parser, get 
the DOM tree representation of a document, and print it to the console.

Alberto

Javier Gálvez Guerrero wrote:
> Hi,
>
> I am a complete newbie and I would like to get some help from the people
> used to Xerces C++ or anybody who could help me.
>
> I want to parse XML files into a C++ structure using DOM representation. I
> know that with SAX, in order to parse the files, startElement, endElement and
> characters interfaces can be overriden and told what to do depending on the
> read tag. I have searched for similar information, if the same interface
> must be overriden when using DOM or which methods I should override or
> create, but I have not found anything.
>
> I would like someone to tell me briefly (or as deep as you want/can...) what
> I should do.
>
>
> Thanks a lot, your help is much appreciated,
>
> Javi
>
>