[jdom-interest] (no subject)

Peter.Horvath at smed.com Peter.Horvath at smed.com
Thu Jun 14 07:27:05 PDT 2001

Hi, as I am new to Java & XML I tried to write simple programs to get an
idea how JDOM works. I downloaded the CVS source files and built a .jar

I have a code segment that produces the following output:

          Namespace ns = Namespace.getNamespace("PREF","Namespace");
          Namespace ns1 = Namespace.getNamespace("Namespace2");

          Element root = new Element("Root");
          Document document = new Document(root);

          Element e1 = new Element("E1");
          e1.addContent("E1 Content");

          Element e2 = new Element("E2");
          e2.addContent("E2 Content");

          Element e3 = new Element("E3");


          Attribute a1 = new Attribute("A1attr", "a1attr value");
          Attribute a2 = new Attribute("A2attr", "a2attr value");
          Attribute atemp = (Attribute) a2.clone();



          XMLOutputter xmloutputter = new XMLOutputter("  ", true);
          try {
               xmloutputter.output(document, System.out);
          } catch(IOException e) {
               System.out.println("IOException = ["+e.getMessage()+"]");

The output XML is this:

<?xml version="1.0" encoding="UTF-8"?>
<Root xmlns="Namespace2">
  <E1 xmlns="" A1attr="a1attr value" A2attr="a2attr value">
    E1 Content
    <E2 A2attr="a2attr value">E2 Content</E2>
  <E3 xmlns="" />

Look element E1 and E3 (xmlns="") . Is this the way the XML output should
look ?

I attached the java source, the xml output and the .jar file. I use Xerces

Thanks for any help.

(See attached file: HPNEWXML.java)

(See attached file: hpnewxml.xml)

(See attached file: JDOMBUILD.jar)

This message and any included attachments are from Siemens Medical Solutions 
Health Services Corporation and are intended only for the addressee(s).  
The information contained herein may include trade secrets or privileged or 
otherwise confidential information.  Unauthorized review, forwarding, printing, 
copying, distributing, or using such information is strictly prohibited and may 
be unlawful.  If you received this message in error, or have reason to believe 
you are not authorized to receive it, please promptly delete this message and 
notify the sender by e-mail with a copy to CSOffice at smed.com.  Thank you
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HPNEWXML.java
Type: application/octet-stream
Size: 1519 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20010614/a472a6c2/HPNEWXML.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hpnewxml.xml
Type: application/octet-stream
Size: 230 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20010614/a472a6c2/hpnewxml.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Type: application/octet-stream
Size: 126090 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20010614/a472a6c2/JDOMBUILD.obj

More information about the jdom-interest mailing list