From ramises.silva at kryptus.com  Fri Jun  2 12:14:20 2017
From: ramises.silva at kryptus.com (=?UTF-8?Q?Ramis=C3=A9s_Martins_da_Silva?=)
Date: Sat Jun  3 09:24:28 2017
Subject: [studxml-users] Escape sequences support
Message-ID: <CAH8pVaOqJDZ0XiX46tpmDA2KFdXVEn+VWjZcTOi+ZyfX7iQc_A@mail.gmail.com>

Hi,

I'm currently trying to parse a xml file that has a nested xml file with
tag delimiters written as escape sequences, to be more clear:

<root>
  <camp1>..</camp1>
  <camp2>..</camp2>
  ....
  <xmlcamp>
    &lt; ncamp1 &gt; data1 &lt; /ncamp1 &gt;
    &lt; ncamp2 &gt; data2 &lt; /ncamp2 &gt;
    ...
  </xmlcamp>
  ...
</>

I'm parsing this by passing the whole xmlcamp element into another file so
the compiler transforms &lt; and &gt; into < and >, so I can actually
extract the data I need by creating another parser. My question is:
is there a way to parse the original xml by telling the parser to interpret
the escape sequences as delimiters?

-- 
*Ramis?s Martins*
From boris at codesynthesis.com  Sat Jun  3 10:15:14 2017
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Sat Jun  3 10:15:23 2017
Subject: [studxml-users] Escape sequences support
In-Reply-To: <CAH8pVaOqJDZ0XiX46tpmDA2KFdXVEn+VWjZcTOi+ZyfX7iQc_A@mail.gmail.com>
References: <CAH8pVaOqJDZ0XiX46tpmDA2KFdXVEn+VWjZcTOi+ZyfX7iQc_A@mail.gmail.com>
Message-ID: <boris.20170603161043@codesynthesis.com>

Hi,

Ramis?s Martins da Silva <ramises.silva@kryptus.com> writes:

>   <xmlcamp>
>     &lt; ncamp1 &gt; data1 &lt; /ncamp1 &gt;
>     &lt; ncamp2 &gt; data2 &lt; /ncamp2 &gt;
>     ...
>   </xmlcamp>
>
> My question is: is there a way to parse the original xml by telling the
> parser to interpret the escape sequences as delimiters?

No, there is no magic switch like this.

If you could somehow detect the end of the escaped fragment (more precisely,
the point in the data stream before '</xmlcamp>' in the example above), then
you could write a custom std::istream implementation that re-injects the
unescaped fragment back into the original data stream so that it is parsed
by the parser as normal XML. This will require some work and will be specific
to your XML document format.

Boris

From ramises.silva at kryptus.com  Mon Jun 19 08:16:10 2017
From: ramises.silva at kryptus.com (=?UTF-8?Q?Ramis=C3=A9s_Martins_da_Silva?=)
Date: Mon Jun 19 09:29:03 2017
Subject: [studxml-users] Attribute mapping
Message-ID: <CAH8pVaMwv14814H=Weo9BFnz+21mQfwDg9rL0piJjRthgzhbdA@mail.gmail.com>

Hi,

I'm trying to parse an xml with multiple objects with attributes, the thing
is I only need to extract some of them. Here's what I'm trying:

If I use attributes_map I get an exception if I don't treat all the
attributes, I wonder if there isn't a way to disable the throwing so I can
actually just deal with the attributes that I need.

If I use attributes_event I don't get the exception but I can't map the
attributes. I would have to look at each event and extract manually the
attribute within a characters event.

Looking for suggestions,

att.

-- 
*Ramis?s Martins*
From boris at codesynthesis.com  Mon Jun 19 12:55:24 2017
From: boris at codesynthesis.com (Boris Kolpackov)
Date: Mon Jun 19 12:55:34 2017
Subject: [studxml-users] Attribute mapping
In-Reply-To: <CAH8pVaMwv14814H=Weo9BFnz+21mQfwDg9rL0piJjRthgzhbdA@mail.gmail.com>
References: <CAH8pVaMwv14814H=Weo9BFnz+21mQfwDg9rL0piJjRthgzhbdA@mail.gmail.com>
Message-ID: <boris.20170619185331@codesynthesis.com>

Ramis?s Martins da Silva <ramises.silva@kryptus.com> writes:

> If I use attributes_map I get an exception if I don't treat all the
> attributes, I wonder if there isn't a way to disable the throwing so I can
> actually just deal with the attributes that I need.

>From xml/parser.hxx:

    // Low-level attribute map access. Note that this API assumes
    // all attributes are handled.
    //

    [...]

    const attribute_map_type&
    attribute_map () const;

So if you want to "mark" all the attributes as handled, simply call this
function.

Boris