Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

Dom parsing with a attribute name with a number sign

Thread view: 
lars.charmer@gmail.com - 19 Sep 2006 20:40 GMT
Hey

I am trying to parse some xml from a ArcIms service, and in the result
xml, one of the attribute names contain a number sign, like  #. When I
trying to parse this xml I get the folowing exception:
[Fatal Error] :1:49: Element type "FIELDS" must be followed by either
attribute specifications, ">" or "/>".
Exception in thread "main" org.xml.sax.SAXParseException: Element type
"FIELDS" must be followed by either attribute specifications, ">" or
"/>".

I have made this small demo program to illustratet my problem:

<java program>
import java.io.ByteArrayInputStream;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;

import org.xml.sax.InputSource;

public class Demo{

   public static void main(String[] args) throws Exception {

       String xmlString = "<?xml version='1.0' encoding='UTF-8' ?>"+
               "<FIELDS  #SHAPE#='[Geometry]' />";

       byte[] byteArr =xmlString.getBytes();
       ByteArrayInputStream bais = new ByteArrayInputStream(byteArr);

       DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
       DocumentBuilder builder = factory.newDocumentBuilder();

       InputSource inputSource = new InputSource(bais);
       Document document = builder.parse(inputSource);
   }
}
</java>

What can I do to solve this problem.
Andrew Thompson - 19 Sep 2006 23:34 GMT
..
> I am trying to parse some xml from a ArcIms service, and in the result
> xml, one of the attribute names contain a number sign, like  #. When I
[quoted text clipped - 4 lines]
> "FIELDS" must be followed by either attribute specifications, ">" or
> "/>".
...
>         String xmlString = "<?xml version='1.0' encoding='UTF-8' ?>"+
>                 "<FIELDS  #SHAPE#='[Geometry]' />";

This suggest to me that '#' is not a valid character for
XML attributes.
<http://www.w3.org/TR/REC-xml/#NT-Name>

> What can I do to solve this problem.

Use valid XML?

Andrew T.
lars.charmer@gmail.com - 20 Sep 2006 09:19 GMT
Easy for you to say. This service/server have returned this kind off
response for the last 6 year, and don't think that ESRI (the company
who's making the ArcIms server), is goving to change it just for me.

Andrew Thompson skrev:

> > What can I do to solve this problem.
>
> Use valid XML?
>
> Andrew T.
lars.charmer@gmail.com - 20 Sep 2006 09:42 GMT
lars.charmer@gmail.com skrev:

> Easy for you to say. This service/server have returned this kind off
> response for the last 6 year, and don't think that ESRI (the company
[quoted text clipped - 7 lines]
> >
> > Andrew T.

Okay it is easy(Sorry Andrew T.). Esri do support valid XML, I just
have to specify you want that. They have a attribute callede outmode
and that should have the value "newxml". But what was they suppose to
when they introduced a invalid XML, and every body was using it,
becaurse that was the default value.

Best regards
Lars Charmer Jørgensen
Andrew Thompson - 20 Sep 2006 10:42 GMT
> lars.charmer@gmail.com skrev:
>
> > Easy for you to say.

Huh?  Your decision to put that comment - floating at
the top, out of context, makes it hard to understand
what you are referring to.

Also - where did the extra indents come from?

The use of '>' preceding your text makes it appear
as if that first paragraph was *quoted* by you.

> > ...This service/server have returned this kind off
> > response for the last 6 year, and don't think that ESRI (the company
[quoted text clipped - 5 lines]
> > >
> > > Use valid XML?
...
> Okay it is easy(Sorry Andrew T.).

I never implied it was easy.  (And I don't see the need for apologies.)

>..Esri do support valid XML, I just
> have to specify you want that.

I want world peace.  This is just an interesting diversion.

Andrew T.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.