< prev index next >
src/java.xml.bind/share/classes/com/sun/xml/internal/bind/marshaller/XMLWriter.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -89,15 +89,15 @@
* w.endDocument();
* </pre>
*
* <p>The resulting document will look like this:</p>
*
- * <pre>
- * <?xml version="1.0" standalone="yes"?>
+ * <pre>{@code
+ * <?xml version="1.0" standalone="yes"?>
*
- * <greeting>Hello, world!</greeting>
- * </pre>
+ * <greeting>Hello, world!</greeting>
+ * }</pre>
*
* <p>In fact, there is an even simpler convenience method,
* <var>dataElement</var>, designed for writing elements that
* contain only character data, so the code to generate the
* document could be shortened to</p>
@@ -123,13 +123,13 @@
* w.dataElement("item", "3");
* </pre>
*
* <p>you will end up with</p>
*
- * <pre>
- * <item>1</item><item>3</item><item>3</item>
- * </pre>
+ * <pre>{@code
+ * <item>1</item><item>3</item><item>3</item>
+ * }</pre>
*
* <p>You need to invoke one of the <var>characters</var> methods
* explicitly to add newlines or indentation. Alternatively, you
* can use {@link DataWriter}, which
* is derived from this class -- it is optimized for writing
@@ -152,15 +152,15 @@
* w.endDocument();
* </pre>
*
* <p>The resulting document will look like this:</p>
*
- * <pre>
- * <?xml version="1.0" standalone="yes"?>
+ * <pre>{@code
+ * <?xml version="1.0" standalone="yes"?>
*
- * <_NS1:foo xmlns:_NS1="http://www.foo.com/ns/"/>
- * </pre>
+ * <_NS1:foo xmlns:_NS1="http://www.foo.com/ns/"/>
+ * }</pre>
*
* <p>In many cases, document authors will prefer to choose their
* own prefixes rather than using the (ugly) default names. The
* XML writer allows two methods for selecting prefixes:</p>
*
@@ -173,15 +173,15 @@
* it attempts to use the name's prefix (as long as the prefix is
* not already in use for another Namespace URI).</p>
*
* <p>The resulting document will look like this:</p>
*
- * <pre>
- * <?xml version="1.0" standalone="yes"?>
+ * <pre>{@code
+ * <?xml version="1.0" standalone="yes"?>
*
- * <foo:foo xmlns:foo="http://www.foo.com/ns/"/>
- * </pre>
+ * <foo:foo xmlns:foo="http://www.foo.com/ns/"/>
+ * }</pre>
*
* <p>The default Namespace simply uses an empty string as the prefix:</p>
*
* <pre>
* w.setPrefix("http://www.foo.com/ns/", "");
@@ -190,32 +190,32 @@
* w.endDocument();
* </pre>
*
* <p>The resulting document will look like this:</p>
*
- * <pre>
- * <?xml version="1.0" standalone="yes"?>
+ * <pre>{@code
+ * <?xml version="1.0" standalone="yes"?>
*
- * <foo xmlns="http://www.foo.com/ns/"/>
- * </pre>
+ * <foo xmlns="http://www.foo.com/ns/"/>
+ * }</pre>
*
* <p>By default, the XML writer will not declare a Namespace until
* it is actually used. Sometimes, this approach will create
* a large number of Namespace declarations, as in the following
* example:</p>
*
- * <pre>
- * <xml version="1.0" standalone="yes"?>
+ * <pre>{@code
+ * <xml version="1.0" standalone="yes"?>
*
- * <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
- * <rdf:Description about="http://www.foo.com/ids/books/12345">
- * <dc:title xmlns:dc="http://www.purl.org/dc/">A Dark Night</dc:title>
- * <dc:creator xmlns:dc="http://www.purl.org/dc/">Jane Smith</dc:title>
- * <dc:date xmlns:dc="http://www.purl.org/dc/">2000-09-09</dc:title>
- * </rdf:Description>
- * </rdf:RDF>
- * </pre>
+ * <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
+ * <rdf:Description about="http://www.foo.com/ids/books/12345">
+ * <dc:title xmlns:dc="http://www.purl.org/dc/">A Dark Night</dc:title>
+ * <dc:creator xmlns:dc="http://www.purl.org/dc/">Jane Smith</dc:title>
+ * <dc:date xmlns:dc="http://www.purl.org/dc/">2000-09-09</dc:title>
+ * </rdf:Description>
+ * </rdf:RDF>
+ * }</pre>
*
* <p>The "rdf" prefix is declared only once, because the RDF Namespace
* is used by the root element and can be inherited by all of its
* descendants; the "dc" prefix, on the other hand, is declared three
* times, because no higher element uses the Namespace. To solve this
@@ -228,22 +228,22 @@
*
* <p>Now, the "dc" prefix will be declared on the root element even
* though it's not needed there, and can be inherited by its
* descendants:</p>
*
- * <pre>
- * <xml version="1.0" standalone="yes"?>
+ * <pre>{@code
+ * <xml version="1.0" standalone="yes"?>
*
- * <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ * <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
* xmlns:dc="http://www.purl.org/dc/">
- * <rdf:Description about="http://www.foo.com/ids/books/12345">
- * <dc:title>A Dark Night</dc:title>
- * <dc:creator>Jane Smith</dc:title>
- * <dc:date>2000-09-09</dc:title>
- * </rdf:Description>
- * </rdf:RDF>
- * </pre>
+ * <rdf:Description about="http://www.foo.com/ids/books/12345">
+ * <dc:title>A Dark Night</dc:title>
+ * <dc:creator>Jane Smith</dc:title>
+ * <dc:date>2000-09-09</dc:title>
+ * </rdf:Description>
+ * </rdf:RDF>
+ * }</pre>
*
* <p>This approach is also useful for declaring Namespace prefixes
* that be used by qualified names appearing in attribute values or
* character data.</p>
*
@@ -370,11 +370,11 @@
encoding = _encoding;
}
/**
* Set whether the writer should print out the XML declaration
- * (<?xml version='1.0' ... ?>).
+ * ({@code <?xml version='1.0' ... ?>}).
* <p>
* This option is set to true by default.
*/
public void setXmlDecl( boolean _writeXmlDecl ) {
this.writeXmlDecl = _writeXmlDecl;
< prev index next >