Comments (12)
Neither, it was because of the hovering over "aWriter", but I could inspect aWriter via Evaluate Expression. I think it is the IDE which is causing this.
from ph-ubl.
I just did, thanks!
from ph-ubl.
Also, then I don't clone the instance, the ns4 prefix is not there.
_xmlns:urn:oasis:names:specification:ubl:schema:xsd:Invoice-2
_xmlns:cac:urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2
_xmlns:cec:urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2
_xmlns:cbc:urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2
Used code:
final ESuccess eSuccess = UBL20Writer.invoice().write(aInvoice, new File(fn));
Why is that?
Thanks!
from ph-ubl.
I could get rid of the prefix by adding this:
aNsCtx.addDefaultNamespaceURI("urn:oasis:names:specification:ubl:schema:xsd:Invoice-2");
But the extra namespace/mapping are not added dough.
from ph-ubl.
Hi. So
MapBasedNamespaceContext aNsCtx = UBL20NamespaceContext.getInstance().getClone();
aNsCtx.addMapping("qdt", "urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2");
aWriter.setNamespaceContext(aNsCtx);
final ESuccess eSuccess = aWriter.write(aInvoice, new File(fn));
would be the correct solution.
What is __prefix:ns4
exactly. Can you paste the XML here?
Is it
prefix="ns4"
or so?
from ph-ubl.
Thanks for your quick reply!
Correct, that's the code I use. However, when I add this line, the "ns4" prefix is not there:
aNsCtx.addDefaultNamespaceURI("urn:oasis:names:specification:ubl:schema:xsd:Invoice-2");
This "__prefix:ns4" is something the XML viewer is showing because of the prefix in the XML file.
I can't drop the XML extension here, so I renamed the file to sample.txt.
from ph-ubl.
Ah okay got it - you have a weird XML viewer ;-)
Try this - combining both:
MapBasedNamespaceContext aNsCtx = UBL20NamespaceContext.getInstance().getClone();
aNsCtx.addMapping("qdt", "urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2");
aNsCtx.addDefaultNamespaceURI("urn:oasis:names:specification:ubl:schema:xsd:Invoice-2");
aWriter.setNamespaceContext(aNsCtx);
final ESuccess eSuccess = aWriter.write(aInvoice, new File(fn));
from ph-ubl.
Yes, that's what I tried in the first place, but it is resulting in an XML without the "ns4" prefix, but without the "qdt" namespace line:
sample2.txt
from ph-ubl.
It is there, but for some reason, it don't gets saved:
from ph-ubl.
It says "thew NullPointerException" - is "fn" or "aInvoice" null
?
from ph-ubl.
Can you send me a bit more code privately - see the pom.xml for my email address. Thx
from ph-ubl.
Reason/solution:
In general, the underlying JAXB only writes the XML namespaces it (whysoever) needs.
And as the qdt namespace ( "urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2") is not used, it is not emitted.
If you would use an element that would require this namespace, than it would be there.
from ph-ubl.
Related Issues (20)
- How to add UBLDocumentSignatures in UBL Extension? HOT 1
- how to change cbc:IssueTime formats HOT 13
- If the Invoice did not have AccountingCustomerParty It will not continue to produce the invoice HOT 2
- eForms support HOT 9
- Implementation of JAXB-API has not been found on module path or classpath. HOT 2
- UBLExtensions HOT 3
- Maven central release of 6.7.0 HOT 1
- EmbeddedDocumentBinaryObjectType value only Bytes() can't be String HOT 5
- In UBLExtension How I can replace prefix "cec" with "ext"? HOT 2
- Invoice xmlns prefix HOT 2
- Error when run createinvoicefromscratch HOT 8
- Fill InvoiceType Object from List<Map<String,String>> HOT 3
- No Prefix is geting added after adding the namespace context HOT 9
- custom XSD schema HOT 5
- Update UBLTR specifications HOT 3
- Master branch can compile using JDK 11 or higher version.But i can only JDK 1.8 version for some reason. HOT 4
- XML cut off on write HOT 1
- Failed to add multiple scheme ID with value in PartyIdentificationType for UBL 2.1 version 9.0.0 HOT 2
- [UBL2.1] Unable to add UBLDocumentSignatures in "UBLExtentions > UBLExtention > ExtensionContent" HOT 2
- sts namespace in Invoice documents HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ph-ubl.