You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by Neil Pitman <ne...@mahjongmania.com> on 2005/08/18 10:10:27 UTC

questions regarding XML document construction

Hello,

 

I've started using Jaxme to good effect for parsing XML documents.  Now I
want to use it to construct documents.  I've come up with several questions.
I'll send them as different mails since they will probably be of interest to
different people

 
The example in the doc creates Impl classes directly.  I've noticed the
ObjectFactory class.  Is this the counselled way to get elements?







  public static void writeAddress(Writer pWriter) throws JAXBException {
    // Create the element:
        ObjectFactory of = new ObjectFactory();
    Address addr = of.createAddress()
    addr.setName(of.createAddressTypeNameType());
    addr.getName().setFirst("Jane");
    addr.getName().setLast("Doe");
    addr.setPostal(of.createAddressTypePostalType());
    addr.getPostal().setStreet("34 Main Street");
    addr.getPostal().setCity("Boston");
    addr.getPostal().setState("MA");
    addr.getPostal().setZIP("02215");
    addr.setEmailDetails(of.createAddressTypeEmailDetailsType());
 

If so, then why is there of.createAddress() and of.createAddressType()?
of.createAddressType() seems only to throw a not found exception.  When is
it used?

 

 


------=_NextPart_000_00CE_01C5A3AA.20CB4F50
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:st1=3D"urn:schemas-microsoft-com:office:smarttags" =
xmlns=3D"http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 11 (filtered medium)">
<o:SmartTagType =
namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags"
 name=3D"City"/>
<o:SmartTagType =
namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags"
 name=3D"place"/>
<o:SmartTagType =
namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags"
 name=3D"Street"/>
<o:SmartTagType =
namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags"
 name=3D"address"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;}
pre
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:"Courier New";
	color:black;}
span.EmailStyle18
	{mso-style-type:personal;
	font-family:Arial;
	color:windowtext;}
span.EmailStyle19
	{mso-style-type:personal-reply;
	font-family:Arial;
	color:navy;}
@page Section1
	{size:612.0pt 792.0pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
	{page:Section1;}
-->
</style>

</head>

<body lang=3DEN-CA link=3Dblue vlink=3Dpurple>

<div class=3DSection1>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Hello,<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>I&#8217;ve started using Jaxme to good effect for =
parsing
XML documents.&nbsp; Now I want to use it to construct documents.&nbsp;
I&#8217;ve come up with several questions.&nbsp; I&#8217;ll send them as
different mails since they will probably be of interest to different =
people<o:p></o:p></span></font></p>

<pre><font size=3D2 color=3Dblack face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial;color:windowtext'><o:p>&nbsp;</o:p></span></font></pre>=
<pre><font
size=3D2 color=3Dblack face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>The example in the doc =
creates Impl classes directly.&nbsp; I&#8217;ve noticed the =
ObjectFactory class.&nbsp; Is this the counselled way to get =
elements?<o:p></o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'><br>
<br>
<o:p></o:p></span></font></pre><pre><font size=3D2 color=3Dblack =
face=3D"Courier New"><span
lang=3DEN style=3D'font-size:10.0pt'>&nbsp; public static void =
writeAddress(Writer pWriter) throws JAXBException =
{<o:p></o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span lang=3DEN =
style=3D'font-size:10.0pt'>&nbsp;&nbsp;&nbsp; // Create the =
element:<o:p></o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span lang=3DEN =
style=3D'font-size:10.0pt'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
ObjectFactory of =3D new =
ObjectFactory();<o:p></o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span lang=3DEN =
style=3D'font-size:10.0pt'>&nbsp;&nbsp;&nbsp; Address addr =3D =
of.createAddress()<o:p></o:p></span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span lang=3DEN =
style=3D'font-size:10.0pt'>&nbsp;&nbsp;&nbsp; =
addr.setName(of.createAddressTypeNameType());<o:p></o:p></span></font></p=
re><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span lang=3DEN =
style=3D'font-size:10.0pt'>&nbsp;&nbsp;&nbsp; =
addr.getName().setFirst(&quot;Jane&quot;);<o:p></o:p></span></font></pre>=
<pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span lang=3DEN =
style=3D'font-size:10.0pt'>&nbsp;&nbsp;&nbsp; =
addr.getName().setLast(&quot;Doe&quot;);<o:p></o:p></span></font></pre><p=
re><font
size=3D2 color=3Dblack face=3D"Courier New"><span lang=3DEN =
style=3D'font-size:10.0pt'>&nbsp;&nbsp;&nbsp; =
addr.setPostal(of.createAddressTypePostalType());<o:p></o:p></span></font=
></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span lang=3DEN =
style=3D'font-size:10.0pt'>&nbsp;&nbsp;&nbsp; =
addr.getPostal().setStreet(&quot;<st1:Street
w:st=3D"on"><st1:address w:st=3D"on">34 Main =
Street</st1:address></st1:Street>&quot;);<o:p></o:p></span></font></pre><=
pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span lang=3DEN =
style=3D'font-size:10.0pt'>&nbsp;&nbsp;&nbsp; =
addr.getPostal().setCity(&quot;<st1:place
w:st=3D"on"><st1:City =
w:st=3D"on">Boston</st1:City></st1:place>&quot;);<o:p></o:p></span></font=
></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span lang=3DEN =
style=3D'font-size:10.0pt'>&nbsp;&nbsp;&nbsp; =
addr.getPostal().setState(&quot;MA&quot;);<o:p></o:p></span></font></pre>=
<pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span lang=3DEN =
style=3D'font-size:10.0pt'>&nbsp;&nbsp;&nbsp; =
addr.getPostal().setZIP(&quot;02215&quot;);<o:p></o:p></span></font></pre=
><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span lang=3DEN =
style=3D'font-size:10.0pt'>&nbsp;&nbsp;&nbsp; =
addr.setEmailDetails(of.createAddressTypeEmailDetailsType());<o:p></o:p><=
/span></font></pre><pre><font
size=3D2 color=3Dblack face=3D"Courier New"><span lang=3DEN =
style=3D'font-size:10.0pt'><o:p>&nbsp;</o:p></span></font></pre>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>If so, then why is there of.createAddress() and
of.createAddressType()?&nbsp; of.createAddressType() seems only to throw =
a not
found exception.&nbsp; When is it used?<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

</div>

</body>

</html>

------=_NextPart_000_00CE_01C5A3AA.20CB4F50--


---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


Re: questions regarding XML document construction

Posted by Jochen Wiedmann <jo...@gmail.com>.
On 8/18/05, Neil Pitman <ne...@mahjongmania.com> wrote:

> The example in the doc creates Impl classes directly.  I've noticed the
> ObjectFactory class.  Is this the counselled way to get elements?

Using the ObjectFactory is indeed recommended and the docs should be
changed here. (Patches welcome. :-)


> If so, then why is there of.createAddress() and of.createAddressType()?
> of.createAddressType() seems only to throw a not found exception.  When is
> it used?

createAddressType() should be working. It is a bug, that it doesn't.
That bug will be changed in 0.6. For now, the workaround is using
createAddress().


Jochen

-- 
What are the first steps on the moon, compared to your child's?

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org