You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2006/05/08 12:19:30 UTC
svn commit: r404999 - /webservices/axis2/trunk/java/xdocs/1_0/OMTutorial.html
Author: dims
Date: Mon May 8 03:19:27 2006
New Revision: 404999
URL: http://svn.apache.org/viewcvs?rev=404999&view=rev
Log:
oops! forgot the source
Modified:
webservices/axis2/trunk/java/xdocs/1_0/OMTutorial.html
Modified: webservices/axis2/trunk/java/xdocs/1_0/OMTutorial.html
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/xdocs/1_0/OMTutorial.html?rev=404999&r1=404998&r2=404999&view=diff
==============================================================================
--- webservices/axis2/trunk/java/xdocs/1_0/OMTutorial.html (original)
+++ webservices/axis2/trunk/java/xdocs/1_0/OMTutorial.html Mon May 8 03:19:27 2006
@@ -261,7 +261,7 @@
<p><b>Code Listing 1</b></p>
</div>
<source><pre>//create the parser<br>
-XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileReader(file));
+XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileInputStream(file));
<br>//create the builder<br>
StAXOMBuilder builder = new StAXOMBuilder(parser);
//get the root element (in this case the envelope)<br>
@@ -413,11 +413,7 @@
root.addChild(elt1);</pre>
<p>Serilization of the root element produces the following XML</p>
-<pre class="xml"><x:root xmlns:x="bar" xmlns:y="bar1">
- <x:foo>
- <y:yuck>blah</y:yuck>
- </x:foo>
-</x:root></pre>
+<pre class="xml"><x:root xmlns:x="bar" xmlns:y="bar1"><x:foo><y:yuck>blah</y:yuck></x:foo></x:root></pre>
<a name="traversing"></a>
<h3>Traversing</h3>
@@ -511,16 +507,10 @@
accurately figure out the namespaces. The example is from Code Listing 6
which creates a small OM programmatically. Serialization of the root element
produces the following,</p>
-<pre class="xml"><x:root xmlns:x="bar" xmlns:y="bar1">
- <x:foo>
- <y:yuck>blah</y:yuck>
- </x:foo>
-</x:root></pre>
+<pre class="xml"><x:root xmlns:x="bar" xmlns:y="bar1"><x:foo><y:yuck>blah</y:yuck></x:foo></x:root></pre>
<p>However serialization of only the foo element produces the following</p>
-<pre class="xml"><x:foo xmlns:x="bar">
-<y:yuck xmlns:y="bar1">blah</y:yuck>
-</x:foo></pre>
+<pre class="xml"><x:foo xmlns:x="bar"><y:yuck xmlns:y="bar1">blah</y:yuck></x:foo></pre>
<p>Note how the serializer puts the relevant namespace declarations in
place.</p>
@@ -535,7 +525,7 @@
<p><b>Code Listing 9</b></p>
</div>
<pre class="code">//create the parser
-XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileReader(file));
+XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileInputStream(file));
//create the builder
StAXOMBuilder builder = new StAXOMBuilder(parser);
@@ -646,19 +636,11 @@
root.addChild(elt1);</pre>
<p>Serialization of the root element provides the following XML</p>
-<pre class="xml"><x:root xmlns:x="bar" xmlns:y="bar1">
-<x:foo>
- <y:yuck>blahblah</y:yuck>
- <y:yuck>blah</y:yuck>
-</x:foo>
-</x:root></pre>
+<pre class="xml"><x:root xmlns:x="bar" xmlns:y="bar1"><x:foo><y:yuck>blahblah</y:yuck><y:yuck>blah</y:yuck></x:foo></x:root></pre>
<p>However if the serialization is carried on the foo element then the
following XML is produced</p>
-<pre class="xml"><x:foo xmlns:x="bar" >
- <y:yuck " xmlns:y="bar1">blahblah</y:yuck>
- <y:yuck " xmlns:y="bar1">blah</y:yuck>
-</x:foo></pre>
+<pre class="xml"><x:foo xmlns:x="bar" ><y:yuck " xmlns:y="bar1">blahblah</y:yuck><y:yuck " xmlns:y="bar1">blah</y:yuck></x:foo></pre>
<p>Note that the same Namespace is serialized twice. This XML is semantically
correct but the same semantics could have been achieved by placing the y
@@ -686,7 +668,7 @@
import org.apache.axis2.impl.llom.factory.OMXMLBuilderFactory;
import javax.xml.stream.*;
-import java.io.FileReader;
+import java.io.FileInputStream;
import java.io.FileNotFoundException;
public class TestOMBuilder {
@@ -698,7 +680,7 @@
public static void main(String[] args) {
try {
//create the parser
- XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileReader(args[0]));
+ XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileInputStream(args[0]));
//get the root element (in this case the envelope)
OMElement documentElement = builder.getDocumentElement();