You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlbeans-cvs@xml.apache.org by er...@apache.org on 2004/03/31 02:09:37 UTC
cvs commit: xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans XmlOptions.java
ericvas 2004/03/30 16:09:37
Modified: v2/src/newstore2/org/apache/xmlbeans/impl/newstore2
Public2.java Saver.java
v2/src/xmlpublic/org/apache/xmlbeans XmlOptions.java
Log:
Add saver options to not save xml decl
Revision Changes Path
1.12 +11 -0 xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/Public2.java
Index: Public2.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/Public2.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Public2.java 30 Mar 2004 21:29:26 -0000 1.11
+++ Public2.java 31 Mar 2004 00:09:37 -0000 1.12
@@ -18,6 +18,8 @@
import javax.xml.stream.XMLStreamReader;
import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Node;
@@ -142,6 +144,15 @@
public static String save ( Node n )
{
return save( n, null );
+ }
+
+ public static void save ( Node n, OutputStream os, XmlOptions options ) throws IOException
+ {
+ XmlCursor c = getCursor( n );
+
+ c.save( os, options );
+
+ c.dispose();
}
public static String save ( Node n, XmlOptions options )
1.22 +4 -1 xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/Saver.java
Index: Saver.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/newstore2/org/apache/xmlbeans/impl/newstore2/Saver.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- Saver.java 30 Mar 2004 21:29:26 -0000 1.21
+++ Saver.java 31 Mar 2004 00:09:37 -0000 1.22
@@ -850,7 +850,10 @@
{
super( c, options );
- if (encoding != null)
+ boolean noSaveDecl =
+ options != null && options.hasOption( XmlOptions.SAVE_NO_XML_DECL );
+
+ if (encoding != null && !noSaveDecl)
{
XmlDocumentProperties props = Locale.getDocProps( c, false );
1.8 +13 -0 xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java
Index: XmlOptions.java
===================================================================
RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlpublic/org/apache/xmlbeans/XmlOptions.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- XmlOptions.java 29 Mar 2004 07:02:48 -0000 1.7
+++ XmlOptions.java 31 Mar 2004 00:09:37 -0000 1.8
@@ -295,6 +295,17 @@
}
/**
+ * This option controls whether saving saves out the XML
+ * declaration (<?xml ... ?>
+ *
+ * @see XmlTokenSource#save(java.io.File, XmlOptions)
+ * @see XmlTokenSource#xmlText(XmlOptions)
+ */
+ public XmlOptions setSaveNoXmlDecl () {
+ return set( SAVE_NO_XML_DECL );
+ }
+
+ /**
* If this option is set, the document element is replaced with the
* given QName when parsing. If null is supplied, the document element
* is removed.
@@ -621,6 +632,8 @@
public static final String SAVE_OUTER = "SAVE_OUTER";
/** @exclude */
public static final String SAVE_INNER = "SAVE_INNER";
+ /** @exclude */
+ public static final String SAVE_NO_XML_DECL = "SAVE_NO_XML_DECL";
/** @exclude */
public static final String LOAD_REPLACE_DOCUMENT_ELEMENT = "LOAD_REPLACE_DOCUMENT_ELEMENT";
---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org