Gerar xml atravez de um xsd

Olá,

Qual a melhor forma de gerar arquivos XML, através de um XSD, utilizando o Netbeans??

Alguem já utilizou alguma ferramenta e recomenda ?

Att.

Francisco

Estive lendo, e se fala bastante no JAXB no netbeans, bem eu fiz um teste seguindo o tutorial…

http://www.netbeans.org/kb/60/websvc/jaxb_pt_BR.html

Eu estou utilizando o XSD

Mas quando tendo mostrar o XML gerado através do XSD, aparece a mensagem de erro :

10/09/2008 11:54:13 testaxsd.Main main
SEVERE: null
javax.xml.bind.MarshalException

  • with linked exception:
    [com.sun.istack.SAXException2: unable to marshal type “xsd.status.TConsStatServ” as an element because it is missing an @XmlRootElement annotation]
    at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:331)
    at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:257)
    at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75)
    at testaxsd.Main.main(Main.java:31)
    Caused by: com.sun.istack.SAXException2: unable to marshal type “xsd.status.TConsStatServ” as an element because it is missing an @XmlRootElement annotation
    at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:244)
    at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:303)
    at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:490)
    at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328)
    … 3 more
    CONSTRUÍDO COM SUCESSO (tempo total: 3 segundos)

O XSD que to usando é esse :

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:ds=“http://www.w3.org/2000/09/xmldsig#” xmlns=“http://www.portalfiscal.inf.br/nfe” xmlns:xs=“http://www.w3.org/2001/XMLSchema” targetNamespace=“http://www.portalfiscal.inf.br/nfe” elementFormDefault=“qualified” attributeFormDefault=“unqualified”>
<xs:include schemaLocation=“tiposBasico_v1.02.xsd”/>
<xs:complexType name=“TConsStatServ”>
xs:annotation
xs:documentationTipo Pedido de Consulta do Status do Serviço</xs:documentation>
</xs:annotation>
xs:sequence
<xs:element name=“tpAmb” type=“TAmb”>
xs:annotation
xs:documentationIdentificação do Ambiente:
1 - Produção
2 - Homologação</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name=“cUF” type=“TCodUfIBGE”>
xs:annotation
xs:documentationSigla da UF consultada</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name=“xServ” type=“TServ” fixed=“STATUS”>
xs:annotation
xs:documentationServiço Solicitado</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name=“versao” type=“TVerConsStatServ” use=“required”/>
</xs:complexType>
<xs:complexType name=“TRetConsStatServ”>
xs:annotation
xs:documentationTipo Resultado da Consulta do Status do Serviço</xs:documentation>
</xs:annotation>
xs:sequence
<xs:element name=“tpAmb” type=“TAmb”>
xs:annotation
xs:documentationIdentificação do Ambiente:
1 - Produção
2 - Homologação</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name=“verAplic” type=“TVerAplic”>
xs:annotation
xs:documentationVersão do Aplicativo que processou a NF-e</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name=“cStat” type=“TStat”>
xs:annotation
xs:documentationCódigo do status da mensagem enviada.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name=“xMotivo” type=“TMotivo”>
xs:annotation
xs:documentationDescrição literal do status do serviço solicitado.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name=“cUF” type=“TCodUfIBGE”>
xs:annotation
xs:documentationCódigo da UF responsável pelo serviço</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name=“dhRecbto” type=“xs:dateTime”>
xs:annotation
xs:documentationAAAA-MM-DDTHH:MM:SS</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name=“tMed” type=“TMed” minOccurs=“0”>
xs:annotation
xs:documentationTempo médio de resposta do serviço (em segundos) dos últimos 5 minutos</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name=“dhRetorno” type=“xs:dateTime” minOccurs=“0”>
xs:annotation
xs:documentationAAAA-MM-DDTHH:MM:SSDeve ser preenchida com data e hora previstas para o retorno dos serviços prestados.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name=“xObs” type=“TMotivo” minOccurs=“0”>
xs:annotation
xs:documentationCampo observação utilizado para incluir informações ao contribuinte</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name=“versao” type=“TVerConsStatServ” use=“required”/>
</xs:complexType>
<xs:simpleType name=“TVerConsStatServ”>
xs:annotation
xs:documentationTipo versão do leiuate da Consulta Status do Serviço 1.07</xs:documentation>
</xs:annotation>
<xs:restriction base=“xs:token”>
<xs:pattern value=“1.07”/>
</xs:restriction>
</xs:simpleType>
</xs:schema>


Abraço,

j.francisco