How are you saving the file? XmlBeans has an method that will write the
contents out to a file and as far as I remember should add the <?xml ...

With regard to adding the namespaces, you can add them via the XmlOptions
class or XmlCursor Api.
best of luck,
-jacobd

On Nov 16, 2007 7:29 AM, Regis Santos <[EMAIL PROTECTED]>
wrote:

> Hello,
>
> I have the following simple XSD file:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
>    xmlns="http://www.allianceconsultoria.com.br/nfe";
>    xmlns:ds="http://www.w3.org/2000/09/xmldsig#";
>    targetNamespace="http://www.alliance.com/nfe";
>    elementFormDefault="qualified" attributeFormDefault="unqualified">
>
>  <xs:element name="cabecMsg">
>    <xs:complexType>
>      <xs:sequence>
>        <xs:element name="dataVersion">
>          <xs:simpleType>
>            <xs:restriction base="xs:decimal">
>              <xs:pattern value="[1-9]{1}[0-9]{0,1}\.[0-9]{2}"/>
>            </xs:restriction>
>          </xs:simpleType>
>        </xs:element>
>      </xs:sequence>
>      <xs:attribute name="version" use="required" fixed="1.02">
>        <xs:simpleType>
>          <xs:restriction base="xs:decimal">
>            <xs:totalDigits value="4"/>
>            <xs:fractionDigits value="2"/>
>          </xs:restriction>
>        </xs:simpleType>
>      </xs:attribute>
>    </xs:complexType>
>  </xs:element>
> </xs:schema>
>
>
> Then I generated the Java classes based in that XMLSchema and tried to
> create a XML file using that classes:
>
> // ...
>
> CabecMsgDocument document = CabecMsgDocument.Factory.newInstance();
> CabecMsgDocument.CabecMsg cabec = document.addNewCabecMsg();
> cabec.setVersion(new BigDecimal("1.02"));
> cabec.setDataVersion(new BigDecimal("1.07"));
> document.setCabecMsg(cabec);
>
> //... save the document
>
>
> The content of the generated XML file was:
>
> <nfe:cabecMsg version="1.02" xmlns:nfe="
> http://www.allianceconsultoria.com.br/nfe";>
>  <nfe:dataVersion>1.07</nfe:dataVersion>
> </nfe:cabecMsg>
>
>
> But the result that I want must be the following:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <cabecMsg xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>  xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>  version="1.02"
>  xmlns:nfe="http://www.allianceconsultoria.com.br/nfe";>
> <dataVersion>1.07</dataVersion>
> </cabecMsg>
>
> In other words: What do I have to do to include the xmlns:xsi and
> xmlns:xsd namespaces and the <?xml version="1.0" encoding="UTF-8"?>
> header?
>
>
> Thanks.
>
> --
> Regis Santos
> E-mail: [EMAIL PROTECTED]
> Alliance Consultoria
> www.allianceconsultoria.com.br
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to