phax / ph-ubl

Java library for reading and writing UBL 2.0, 2.1, 2.2, 2.3 and 2.4 (CS01) documents

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: namespaces prefixes

jpaezlancheros opened this issue · comments

Hello Phax

I find Intereseting this libraries for UBL. I am making a test to use it in Colombia. I saw yo in a thread you solved a case appearing ns4 prefix in root. I am doing this:

aBuilder.setNamespaceContext(UBL22NamespaceContext.getInstance() );

and result xml is

<ns4:Invoice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns4="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xsi:schemaLocation="http://www.dian.gov.co/contratos/facturaelectronica/v1 ../../../schemas/XSD/r1/DIAN_UBL.xsd

no matter what I put in UBL22NamespaceContext

bu I am not able to see or to understand how can be changed the "ns4" prefix.

what i need is something like this

<fe:Invoice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns4="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"

That's pretty simple. Try it like this:

MapBasedNamespaceContext aNsCtx = UBL22NamespaceContext.getInstance().getClone ();
aNsCtx.addMapping ("fe", "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2");
aBuilder.setNamespaceContext(aNsCtx);

hth

Hello

ThankYou very Much

it Works Perfect!

Jorge