[jdom-interest] [Newbie] - Problem using Entity

philip.nelson at omniresources.com philip.nelson at omniresources.com
Tue May 8 17:06:54 PDT 2001


I cant' say that I'm exactly sure what you are trying to output but I can
tell that I have rewriting the entity api to base it on entities defined in
the dtd.  I have been a little bit waylaid with *real work* though.  What
did you want it to look like?

> I'm trying from a java program to output a data structure to 
> XML, so other
> applications can use this information as smoothly as 
> possible. I am a newbie,
> so I might use the JDOM API totally wrong, but I take a 
> chance on asking you
> nevertheless:
> 
> When adding entities, I assume they are supposed to be added 
> to Elements with
> addContent(Entity). Code runs smoothly, but when printing to file, all
> entities within an Element is displayed somewhat 
> un-well-formed :-). Look
> below:
> 
> <Folder id="0">
>  <Folder id="185">
> &Name;  <Folder id="195">
> &Name;   <Item price="0.0">
>     <Description />
>     <UserDefined>
> &Comment;&Title;&Bitrate;&Year;    </UserDefined>
>    </Item>
>    <Item price="0.0">
>     <Description />
>     <UserDefined>
> &Comment;&Title;&Bitrate;&Year;    </UserDefined>
>    </Item>
>   </Folder>
>  </Folder>
> </Folder>
> 
> As you can see here, I'm adding MP3 file info to an XML file, 
> but all entity
> info is printed as above. Lets add some code which I'm using as well:
> 
>     /* Add new subelement to currentElement and give it an ID 
> attribute and
> name, as all other Elements */
>     Element subElement=new Element("Folder");
>     Entity tmpEntity = new 
> Entity("Name").setContent(tmpNode.getName());
>     subElement.addContent(tmpEntity);
>     subElement.addAttribute("id", 
> Integer.toString(tmpNode.getNodeNumber()));
>     currentElement.addContent(subElement);
> 
> and
> 
>    while(keysEnum.hasMoreElements()) {
>     Object key=keysEnum.nextElement();
>     Entity userDefinedEntity=new Entity(key.toString());
>     
> userDefinedEntity.setContent(thisUserDefined.getValue(key).toS
> tring());
>     userDefinedElement.addContent(userDefinedEntity);
>    }
> 
> As you can see - every time I try to output my Element data 
> structure, it
> goofs up like this. What do I do wrong? Are there any good 
> examples out there?
> I am using XMLoutputter.
> 
> 
> - yours sincerely...
> - Jakob Breivik Grimstveit, jakob at grimstveit.net, www.grimstveit.net
> - Morvikbotn 341, 5121 Ulset, Norway, tlf: 55195667, mob: 98833857
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yo
uraddr at yourhost.com



More information about the jdom-interest mailing list