/******************************************************************************
 * Copyright (c) 2000-2025 Ericsson Telecom AB
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
 *
 * Contributors:
 *   Balasko, Jeno
 *   Raduly, Csaba
 *
 ******************************************************************************/
module NamespacesDup {
modulepar boolean NamespacesDup_verbose := false;
#define verbose NamespacesDup_verbose
#include "../macros.ttcnin"

// Check that namespaces with the same URI but different prefix can coexist
// (see also the global namespace on the module). Compilation only.
type record T1 {
  integer i
}
with {
  variant "namespace as 'urn:ns:1' prefix 'p1'"
}

type record T2 {
  boolean b
}
with {
  variant "namespace as 'urn:ns:1' prefix 'p2'"
}

// -- -- -- -- Check propagation of attributes across nameless types -- -- -- --

type component NSD {}

group g1 {
  type record IndT {
    record { // nameless type
      record { // nameless type
        boolean deepest
      } deep
    } content optional
  }
  with {
    variant "element";
  }
}
with {
  variant "namespace as 'http://www.example.org/group' prefix 'g' "
  variant "elementFormQualified"
}

DECLARE_XER_ENCODERS(IndT, it);
DECLARE_EXER_ENCODERS(IndT, it);

const IndT c_it := {
  content := {
    deep := {
      deepest := true
    }
  }
}

const universal charstring estr_it :=
"<g:IndT xmlns:g='http://www.example.org/group'>\n" &
"\t<g:content>\n" &
"\t\t<g:deep>\n" &
"\t\t\t<g:deepest>true</g:deepest>\n" &
"\t\t</g:deep>\n" &
"\t</g:content>\n" &
"</g:IndT>\n\n";

const universal charstring bstr_it :=
"<IndT>\n" &
"\t<content>\n" &
"\t\t<deep>\n" &
"\t\t\t<deepest><true/></deepest>\n" &
"\t\t</deep>\n" &
"\t</content>\n" &
"</IndT>\n\n";

testcase enc_it() runs on NSD
{
  CHECK_METHOD(bxer_enc_it, c_it, bstr_it);
  CHECK_METHOD(exer_enc_it, c_it, estr_it);
}

testcase dec_it() runs on NSD
{
  CHECK_DECODE(bxer_dec_it, bstr_it, IndT, c_it);
  CHECK_DECODE(exer_dec_it, estr_it, IndT, c_it);
}

control {
  execute(enc_it());
  execute(dec_it());
}

}
with {
encode "XML"
variant "namespace as 'urn:ns:1' prefix 'global'" 
variant "elementFormQualified";
variant "attributeFormQualified";
}
