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