Re: [xml] Need help on normalization/canonicalization with namespace prefix rewrite



Hi Alexey,

I'm trying to get canonicalized xml (not according to standard) text to sign it.
I need to rewrite namespace prefixes for that.
I modified c14n.c to meet my certain requirements - it is suitable for my particular rules.
I included examples of xml i need in my previous emails.
So I hardcoded my namespace prefixes so it works for this case.
Would appretiate if somebody advise on how to achive that with no code change.

Regards,
Mikhail

On Mon, Jan 29, 2018 at 10:44 PM, Aleksey Sanin <aleksey aleksey com> wrote:
I don't understand what are you trying to do so I really don't have
a good answer for you.

Aleksey

On 1/29/18 12:33 AM, Mikhail Goloborodko wrote:
> Alexey,
>
> Thank you!
> I'am new to libxml2. Would appretiate if you advice how to achieve this.
> May be I need a callback for in Reader or Writer?
>
> Mikhail
>
> On Sun, Jan 28, 2018 at 10:02 PM, Aleksey Sanin <aleksey aleksey com
> <mailto:aleksey aleksey com>> wrote:
>
>     I am not sure what is the suggest algorithm to "rewrite namespace
>     prefixes". Regardless, this is not part of C14N spec and something
>     you will have to do yourself.
>
>     Aleksey
>
>     On 1/28/18 3:19 AM, Mikhail Goloborodko wrote:
>     > Hi All,
>     >
>     > I will appreciate if somebody could help on how to normalize and
>     > canonicalize XML.
>     >
>     > For example
>     > <?xml version="1.0" encoding="WINDOWS-1251"?>
>     > <ed:N1 attr="4583001999 <tel:4583001999>" xmlns:ed="urn:ru:ed:v2.0">
>     > </ed:N>
>     >
>     > I need to get
>     >
>     > <n1:N1 xmlns:n1="urn:cbr-ru:ed:v2.0" attr="4583001999"></n1:N1>
>     >
>     > And for
>     >
>     > <?xml version="1.0" encoding="WINDOWS-1251"?>
>     > <N1 attr="4583001999" xmlns="urn:ru:ed:v2.0">
>     >   <N2 attr="value"></N2>
>     > </N1>
>     >
>     > I need
>     >
>     > <n1:N1 xmlns:n1="urn:ru:ed:v2.0"> attr="4583001999"<n1:N2
>     > attr="value"></n1:N2></n1:N1>
>     >
>     > In other words I need to remove whitespaces and rewrite namespace
>     prefixes
>     > I use
>     > string src;
>     > xmlChar * canon;
>     > xmlDocPtr xDoc = xmlReadMemory(src.data(), src.size(), nullptr,
>     nullptr,
>     > XML_PARSE_NOBLANKS);
>     > int bytes = xmlC14NDocDumpMemory(xDoc, nullptr, 0, nullptr, 0, &
>     canon);
>     >
>     > It removes whitespaces, need help with namespace prefix rewrite.
>     >
>     > Thank you in advance.
>     >
>     > On Sun, Jan 28, 2018 at 12:41 AM, Mikhail Goloborodko
>     > <mgoloborodko gmail com <mailto:mgoloborodko gmail com>
>     <mailto:mgoloborodko gmail com <mailto:mgoloborodko gmail com>>> wrote:
>     >
>     >     Hi,
>     >
>     >     I need help on how to normalize and canonicalize XML.
>     >     For example
>     >     <?xml version="1.0" encoding="WINDOWS-1251"?>
>     >     <ed:N1 attr="4583001999 <tel:4583001999>"
>     xmlns:ed="urn:ru:ed:v2.0">
>     >     </ed:N>
>     >
>     >     I need to get
>     >
>     >     <n1:N1 xmlns:n1="urn:cbr-ru:ed:v2.0" attr="4583001999"></n1:N1>
>     >
>     >     And for
>     >
>     >     <?xml version="1.0" encoding="WINDOWS-1251"?>
>     >     <N1 attr="4583001999" xmlns="urn:ru:ed:v2.0">
>     >       <N2 attr="value"></N2>
>     >     </N1>
>     >
>     >     I need
>     >
>     >     <n1:N1 attr="4583001999" xmlns="urn:ru:ed:v2.0"><n1:N2
>     >     attr="value"></n1:N2></n1:N1>
>     >
>     >     In other words I need to remove whitespaces and rewrite namespace
>     >     prefixes
>     >     I use
>     >     string src;
>     >     xmlChar * canon;
>     >     xmlDocPtr xDoc = xmlReadMemory(src.data(), src.size(), nullptr,
>     >     nullptr, XML_PARSE_NOBLANKS);
>     >     int bytes = xmlC14NDocDumpMemory(xDoc, nullptr, 0, nullptr, 0,
>     & canon);
>     >
>     >     It clearly removes whitespace, need help with namespace prefix
>     rewrite.
>     >
>     >     Thank you in advance.
>     >
>     >     Mikhail 
>     >
>     >
>     >
>     >
>     > _______________________________________________
>     > xml mailing list, project page  http://xmlsoft.org/
>     > xml gnome org <mailto:xml gnome org>
>     > https://mail.gnome.org/mailman/listinfo/xml
>     <https://mail.gnome.org/mailman/listinfo/xml>
>     >
>
>



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