R: Re: R: Re: How to use libxml++ to write a file in c ++ xml



I followed your tips Kiel,

I downloaded the code of libxml2 vers. 2.6.26, and I changed into the module xmlsave.c, the method xmlNodeDumpOutputInternal.

Tthe problem is related to the setting of the "format" parameter:


format = ctxt-> format;
     if (format == 1)

    {
              tmp = cur-> children;
              while (tmp! = NULL)

              {
                      if ((tmp-> type == XML_TEXT_NODE) | |
                          (tmp-> type == XML_CDATA_SECTION_NODE))

                     {
-------->>>>>>>>>> / / (Tmp-> type == XML_ENTITY_REF_NODE)) {
                           ctxt-> format = 0;
                            break;
                     }
                     tmp = tmp-> next;
              }
     }

I commented out the line :


      (Tmp-> type == XML_ENTITY_REF_NODE)


 and I compiled the library and installed, it seems that now everything is OK ........


What do you think?


----Messaggio originale----
Da: kjell ahlstedt bredband net
Data: 29/01/2012 17.11
A: "carlo esposito"<kevinstar libero it>
Cc: <libxmlplusplus-list gnome org>
Ogg: Re: R: Re: How to use libxml++ to write a file in c ++ xml

The Document::write_*_formatted() methods turn off formatting in an element that contains a child node of type TextNode, CdataNode, or EntityReference, and recursively in all the element's child elements. It's not libxml++'s fault. It's how the underlying libxml2 functions behave.

I have not found this behaviour documented anywhere. I had to check libxml2's source code to understand what's going on. If you're interested, look at http://git.gnome.org/browse/libxml2/tree/xmlsave.c function xmlNodeDumpOutputInternal() line 944. (The line number may change, if the file is edited.) Obviously the behaviour is by design. Probably we have to accept it. If you think it's worth the trouble, you can file a libxml2 bug. At least it would be fine to have the behaviour documented.

Of course you can get the output you want by adding text nodes with all the linefeeds and spaces that you want, but it would be tedious.

Kjell

2012-01-28 00:29, carlo esposito skrev:

Tested, but the output is not formatted :

<example>
   &xml; <example1> text </ example1> <example2> text </ Example2> </ example>

instead of:

<example>
      &xml;
     <example1>
          text
     </ example1>
     <example2>
          text
      </ Example2>
</ example>


mmmmm......I am very confused .....is not possible !!!!!!!

it seems that not exist the character LF+CR.......


----Messaggio originale----
Da: kevinstar libero it
Data: 27/01/2012 21.54
A: <kjell ahlstedt bredband net>
Cc: <libxmlplusplus-list gnome org>
Ogg: R: Re: How to use libxml++ to write a file in c ++ xml

Thank you,
I try and I will give the test results !!!!


----Messaggio originale----
Da: kjell ahlstedt bredband net
Data: 27/01/2012 16.29
A: "carlo esposito"<kevinstar libero it>
Cc: <libxmlplusplus-list gnome org>
Ogg: Re: How to use libxml++ to write a file in c ++ xml

I think something is missing in xmlpp::Element. There is no way to create an xmlpp::EntityReference or an xmlpp::ProcessingInstructionNode. (They can be created when you parse an xml file, but I can find no way to create an xml file with those nodes without resorting to functions in the underlying libxml2.)

In the attached small program I have added an add_child_entity_reference() function. Then it's possible to write the file you want. I recommend that you file a bug on libxml++.

Kjell

2012-01-26 10:35, carlo esposito skrev:

Hi,
I'm using libxml + + library in C + +, and I have to write an xml file in which there is an inclusion of another xml file:

1 <? Xml version = "1.0"?>
2 <! DOCTYPE EXAMPLE SYSTEM "example.dtd" [
3 <! ENTITY xml "Extensible Markup Language">
4]>
5 <example>
6 &xml;
7 </ example>

I do not know
which the method to use the library libxml++ to write the line 6: "& xml" ,I saw the classes Document, Element, ..... but I have not found any method to use to write code in my xml file line 6.
Can you help ?

 











[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]