1

I'm required to send an XML with the following elements:

<return>
    <getrooms>true</getrooms>
    <filters xmlns:a="http://some.com/xsd/atomicCondition" xmlns:c="http://some.com/xsd/complexCondition">
        <city></city>
        <country></country>
        <c:condition>
            <a:condition>
                <fieldname>fieldName</fieldname>
                <fieldtest>fieldTest</fieldtest>
                <fieldvalues>
                    <fieldvalue>fieldValue</fieldvalue>
                </fieldvalues>
            </a:condition>
            <operator>operator</operator>
            <a:condition>
                <fieldname>fieldName</fieldname>
                <fieldtest>fieldTest</fieldtest>
                <fieldvalues>
                    <fieldvalue>fieldValue</fieldvalue>
                 </fieldvalues>
            </a:condition>
         </c:condition>
    </filters>
    <resultsperpage></resultsperpage>
    <page></page>
</return>

I'm having difficulty forming the "c:condition" and "a:condition" Qname using Jsonix. Both Qname contains a Prefix but don't have the namespace.

My current code is:

{
    type: 'element',
    name: 'ccondition',
    elementName: {
        localPart: 'condition',
        prefix: 'c',
        namespaceURI: 'c'
    },
    typeInfo: 'DOXML.ComplexCondition'
},

This will result in the following:

<c:condition xmlns:c="c">

Anyone knows how to use Jsonix to generate the required Qname - "c:condition" that is without the namespaceURI?

codingKit
  • 13
  • 4

1 Answers1

0

In your example, the prefix c is actually bound to the namespace http://some.com/xsd/complexCondition in this line:

<filters xmlns:a="http://some.com/xsd/atomicCondition" xmlns:c="http://some.com/xsd/complexCondition">

Both you prefixes a und c are bound to non-empty namespaces within the scope of the filters element.

So you should actually do:

{ type: 'element', name: 'ccondition', elementName: { localPart: 'condition', prefix: 'c', namespaceURI: 'http://some.com/xsd/complexCondition' }, typeInfo: 'DOXML.ComplexCondition' }

I think you should be able to map to the empty namespace with namespaceURI: '', but this is not what you need in your case, if I see it correctly.

lexicore
  • 42,748
  • 17
  • 132
  • 221
  • Hi lexicore! Yup, that still ends in ``, still don't match the XML format as provided above. The expected one is ``. – codingKit Jul 07 '17 at 06:46
  • You seem to have ignored the part of my answer where I said that you actually have `xmlns:c="http://some.com/xsd/complexCondition"` here. You therefore should use `namespaceURI: 'http://some.com/xsd/complexCondition'`. – lexicore Jul 09 '17 at 19:52
  • Hi @lexicore I don't understand what you mean by using `namespaceURI: 'http://some.com/xsd/complexCondition'` and then mapping it with `namespaceURI: ''` . Following the below `{ type: 'element', name: 'ccondition', elementName: { localPart: 'condition', prefix: 'c', namespaceURI: 'http://some.com/xsd/complexCondition' }, typeInfo: 'DOXML.ComplexCondition' }` The result will be `` – codingKit Jul 10 '17 at 03:16
  • Using context to add in the `namespaceURI` to ``, Jsonix still don't allow `namespaceURI=''` – codingKit Jul 10 '17 at 03:20
  • *and then mapping it with* I never said "and then". I said you should be able to use empty namespace (`namespaceURI: ''`) and that is not what you want. – lexicore Jul 10 '17 at 11:08
  • *The result will be ``* - correct and this is what you effectively have in your XML example. In your XML example the namespace prefix `c` is bound to `http://some.com/xsd/complexCondition`. So this result is correct in respect to your XML example. – lexicore Jul 10 '17 at 11:11
  • Thank you! I got what you mean now. I stumbled to another problem. I will update the main question. – codingKit Jul 12 '17 at 10:39