< prev index next >

src/java.xml.bind/share/classes/com/sun/xml/internal/txw2/output/XMLWriter.java

Print this page


   1 /*
   2  * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 151  * <pre>
 152  * w.startDocument();
 153  * w.emptyElement("http://www.foo.com/ns/", "foo");
 154  * w.endDocument();
 155  * </pre>
 156  *
 157  * <p>The resulting document will look like this:</p>
 158  *
 159  * <pre>{@code
 160  * <?xml version="1.0" standalone="yes"?>
 161  *
 162  * <_NS1:foo xmlns:_NS1="http://www.foo.com/ns/"/>
 163  * }</pre>
 164  *
 165  * <p>In many cases, document authors will prefer to choose their
 166  * own prefixes rather than using the (ugly) default names.  The
 167  * XML writer allows two methods for selecting prefixes:</p>
 168  *
 169  * <ol>
 170  * <li>the qualified name</li>
 171  * <li>the {@link #setPrefix setPrefix} method.</li>
 172  * </ol>
 173  *
 174  * <p>Whenever the XML writer finds a new Namespace URI, it checks
 175  * to see if a qualified (prefixed) name is also available; if so
 176  * it attempts to use the name's prefix (as long as the prefix is
 177  * not already in use for another Namespace URI).</p>
 178  *
 179  * <p>Before writing a document, the client can also pre-map a prefix
 180  * to a Namespace URI with the setPrefix method:</p>
 181  *
 182  * <pre>
 183  * w.setPrefix("http://www.foo.com/ns/", "foo");
 184  * w.startDocument();
 185  * w.emptyElement("http://www.foo.com/ns/", "foo");
 186  * w.endDocument();
 187  * </pre>
 188  *
 189  * <p>The resulting document will look like this:</p>
 190  *
 191  * <pre>{@code


   1 /*
   2  * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 151  * <pre>
 152  * w.startDocument();
 153  * w.emptyElement("http://www.foo.com/ns/", "foo");
 154  * w.endDocument();
 155  * </pre>
 156  *
 157  * <p>The resulting document will look like this:</p>
 158  *
 159  * <pre>{@code
 160  * <?xml version="1.0" standalone="yes"?>
 161  *
 162  * <_NS1:foo xmlns:_NS1="http://www.foo.com/ns/"/>
 163  * }</pre>
 164  *
 165  * <p>In many cases, document authors will prefer to choose their
 166  * own prefixes rather than using the (ugly) default names.  The
 167  * XML writer allows two methods for selecting prefixes:</p>
 168  *
 169  * <ol>
 170  * <li>the qualified name</li>
 171  * <li>the {@link #startPrefixMapping(String, String)} method.</li>
 172  * </ol>
 173  *
 174  * <p>Whenever the XML writer finds a new Namespace URI, it checks
 175  * to see if a qualified (prefixed) name is also available; if so
 176  * it attempts to use the name's prefix (as long as the prefix is
 177  * not already in use for another Namespace URI).</p>
 178  *
 179  * <p>Before writing a document, the client can also pre-map a prefix
 180  * to a Namespace URI with the setPrefix method:</p>
 181  *
 182  * <pre>
 183  * w.setPrefix("http://www.foo.com/ns/", "foo");
 184  * w.startDocument();
 185  * w.emptyElement("http://www.foo.com/ns/", "foo");
 186  * w.endDocument();
 187  * </pre>
 188  *
 189  * <p>The resulting document will look like this:</p>
 190  *
 191  * <pre>{@code


< prev index next >