/******************************************************************************
 * 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:
 *   Szabados, Kristof *
 ******************************************************************************/
module XER_EncDec_14 {

type component Test_CT{};


type record of universal charstring any_elem_rec_of with {
  encode "XML";
  variant([-]) "anyElement except unqualified";
}

external function ef_xer_enc(in any_elem_rec_of par) return octetstring 
  with { extension "prototype(convert) encode (XER:XER_EXTENDED) errorbehavior(ALL:ERROR)" }

testcase tc_any_elem() runs on Test_CT {
  var octetstring os_enc;    

  var any_elem_rec_of v_good := { "<xyz:color xmlns:xyz=""http://www.somewhere.com"">red</xyz:color>" };
  os_enc := ef_xer_enc(v_good);

@try {
  var any_elem_rec_of v_bad := { "<something>not very important</something>" };
  os_enc := ef_xer_enc(v_bad); 
} @catch (msg) {
  var template charstring msg_exp := pattern "*Dynamic test case error: While XER-encoding type '@XER_EncDec_14.any_elem_rec_of': Index 0: While checking anyElement: The unqualified XML namespace is in the excluded namespace list*";
  if (not match(msg, msg_exp)) {
    setverdict(fail, "Invalid error message: ", msg);
  } else {
    setverdict(pass);
  }
}
  setverdict(pass);
}

control {
  execute(tc_any_elem());
}

}
