The method I was thinking of is actually XmlOptions<http://xmlbeans.apache.org/docs/2.2.0/reference/org/apache/xmlbeans/XmlOptions.html> *setSaveAggressiveNamespaces<http://xmlbeans.apache.org/docs/2.2.0/reference/org/apache/xmlbeans/XmlOptions.html#setSaveAggressiveNamespaces%28%29> *() Causes the saver to reduce the number of namespace prefix declarations.
Take a peek at the other methods that help when working with namespaces http://xmlbeans.apache.org/docs/2.2.0/reference/org/apache/xmlbeans/XmlOptions.html -jacobd On Nov 16, 2007 11:11 AM, Regis Santos <[EMAIL PROTECTED]> wrote: > Hello Jacob, > > My XMLBeans version is 2.1.0 and I didn't find the method > setSaveAggressivePrefix() in XmlOptions class. Maybe you can help me to find > another method that remove prefixes. I've read the documentation api from > 2.2.0 version, but there's no such method too. > > About the xml header, I'm writing the string "<?xml version="1.0" > encoding="UTF-8"?> in the OutputStream before saving the document. It solved > the problem, but I think that it's not much elegant, isn't it? > > Regards. > > Regis > > > -----Mensagem original----- > *De:* Jacob Danner [mailto:[EMAIL PROTECTED] > *Enviada em:* sexta-feira, 16 de novembro de 2007 15:43 > *Para:* [EMAIL PROTECTED];[email protected] > > *Assunto:* Re: Missing namespaces and XML header > > Is there a way to save xml file without the prefixes "nfe:" from the tags? > yep, look into the methods on the XmlOptions Api > I've used setSaveAggressivePrefix but there are other methods that may be > used for that. > -jacobd > > > On Nov 16, 2007 9:40 AM, Regis Santos < [EMAIL PROTECTED]> > wrote: > > > Hi Jacob. > > > > I invoke the document.save(OutputStream out) to save the content in a > > XML file. > > > > Is there a way to save xml file without the prefixes "nfe:" from the > > tags? > > > > I tried the method insertNamespace() from XmlCursor and it works! =c) > > > > Thanks for help > > > > Regis > > > > > > -----Mensagem original----- > > *De:* Jacob Danner [mailto:[EMAIL PROTECTED] > > *Enviada em:* sexta-feira, 16 de novembro de 2007 15:06 > > *Para:* [email protected];[EMAIL PROTECTED] > > *Assunto:* Re: Missing namespaces and XML header > > > > 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] > > > > > > > > >

