Note that there are some explanatory texts on larger screens.

plurals
  1. POJAXB XML Unmarshaller
    primarykey
    data
    text
    <p>I am using JAXB and RestEasy. </p> <p>I am returning a Comprobante.class (JAXB generated class) from a xml file that needs to have:</p> <pre><code>&lt;cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd"&gt;...&lt;/cfdi:Comprobante&gt; </code></pre> <p>I have this at package declaration:</p> <pre><code>@XmlSchema( location = "http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd", namespace = "http://www.sat.gob.mx/cfd/3", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED, attributeFormDefault = javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED, xmlns={ @XmlNs( prefix="cfdi", namespaceURI="http://www.sat.gob.mx/cfd/3" ), @XmlNs( prefix="xsi", namespaceURI="http://www.w3.org/2001/XMLSchema-instance" ) }) </code></pre> <p>But the result of the unmarshaling from the XML file to the JAXB class doesn't have the:</p> <pre><code>xsi:schemaLocation="http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd" </code></pre> <p>It only prints</p> <pre><code>&lt;cfdi:Comprobante xmlns:cfdi="http://www.sat.gob.mx/cfd/3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;..&lt;/cfdi:Comprobante&gt; </code></pre> <p>My code is:</p> <pre><code>File p = new File(servletContext.getRealPath("/")+factura.getXml().getCfdi()); JAXBContext context = JAXBContext.newInstance("foo.bar.Model.CFDIv32"); Unmarshaller u = context.createUnmarshaller(); return (foo.bar.Comprobante) u.unmarshal(p); </code></pre> <p>How can i tell to JAXB Unmarshaller to put the xsi:schemaLocation="" property.</p> <p>Thank you.</p> <h2>EDIT: how i solved it</h2> <p>See my own answer</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload