Menu

Multiple Namespaces in one element

Get Help
Anonymous
2017-11-21
2017-11-22
  • Anonymous

    Anonymous - 2017-11-21

    Hi Rumen,
    can you tell me how it is possible to declare multiple namespaces for one element? What I am trying to create is:
    <Song xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.webucator.com/Song" xmlns:art="http://www.webucator.com/Artist" xsi:schemaLocation="http://www.webucator.com/Song Song.xsd">
    (This is just an example from https://www.webucator.com/tutorial/learn-xml-schema/namespaces/using-multiple-namespaces-reading.cfm). The element is the first one in my document after the xml version declaration.
    What i have already tried right now is to use the function 'serialize.namespaceDeclaration'. The problem is that the function always returns 9/EXIP_INVALID_EXI_INPUT due to the fact that the preserved option in the header is not set. But every time i wanted to set it with 'SET_PRESERVED(testStrm.header.opts.preserve,PRESERVE_PREFIXES);' after initHeader or at any other position the program crashes caused by a segmentation fault.
    Do you know the reason? It might be a simple usage failure by i do not know the reason.
    But nevertheless EXIP is a very good code to interact with EXI files. Thanks for uploading it!

     
  • Rumen Kyusakov

    Rumen Kyusakov - 2017-11-21

    Hi,

    You can have a look at a test in the exip test suite which has namespaces and use it as an example.
    Please see file tests/check_exip.c

    The function for encoding a document with a namespace is encodeWithDynamicTypes()

    I hope this helps.

    Best regards,
    Rumen

     
  • Anonymous

    Anonymous - 2017-11-22

    Thanks for you answer. I was able to solve the problem with it.
    But now i have another problem regarding the first element of my xml/exi file.
    It should lool like: <ns:element xmlns:ns2="somenamespace"> [...] </ns:element>.
    But what it actually looks like is: <element xmlns:ns2="somenamespace"> [...] </element>.
    So i need to declare the namespace before starting the first element. I already tried to use the field 'prefix' in the structure QName but there was no effect. When is set the uri field of the struct there is no prefix in front of the following elements of this namespace. The settings for the stream are as followed:
    testStrm.header.has_options = TRUE;
    testStrm.header.opts.valuePartitionCapacity=0;
    SET_PRESERVED(testStrm.header.opts.preserve, PRESERVE_PREFIXES);
    SET_ALIGNMENT(testStrm.header.opts.enumOpt,BIT_PACKED);
    testStrm.header.opts.schemaIDMode = SCHEMA_ID_EMPTY;
    Kind regards,
    Tobias

     
  • Rumen Kyusakov

    Rumen Kyusakov - 2017-11-22

    Hi Tobias,

    I am not sure I understand the issue.
    You are saying the first element should look like this

    <ns:element xmlns:ns2="somenamespace"> [...] </ns:element>

    but then the ns prefix is never declared.

    My guess is that it should be something like:

    <ns:element xmlns:ns="a_namespace" xmlns:ns2="somenamespace"> [...] </ns:element>

    In this case you need to set local-element-ns for "a_namespace" NS to true.

    I hope this helps.

    Regards,
    Rumen

     
  • Anonymous

    Anonymous - 2017-11-22

    Hey,
    sorry for that failure in my description. I ment it as you wrote. With this information i was able to fix my problems! Thanks for your support.
    Kind regards,
    Tobias

     

Anonymous
Anonymous

Add attachments
Cancel