?
Solved

XML problem

Posted on 2003-03-09
5
Medium Priority
?
249 Views
Last Modified: 2013-11-23
If my program try to parse a xml file which starts with
<?xml version="1.0"?>
<!DOCTYPE symbolDefinition SYSTEM "C:\symbol.dtd">    
it gives an error. The program works fine if the xml file starts with
<?xml version="1.0"?>
<!DOCTYPE symbolDefinition SYSTEM "symbol.dtd">
.
The error says its something to do with URI but I don't know how to over come this problem. The file "symbol.dtd" exists in the correct directory.

the following is the code to parse XML files.

Thanx



DocumentBuilderFactory factory
              = DocumentBuilderFactory.newInstance();
          factory.setValidating(true);
          factory.setIgnoringElementContentWhitespace(true);
          DocumentBuilder builder = factory.newDocumentBuilder();
     Document doc = builder.parse(zin);


0
Comment
Question by:asukai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 8097837
 Can you post the exact error messages and the versoin of XML parser you are using? Latest versions of Xerces have problems with paths since the expect everything to be a URI.
0
 

Author Comment

by:asukai
ID: 8097896
It's rather long error
org.xml.sax.SAXParseException: Relative URI "C:\symbol.dtd"; can not be reso
lved without a base URI.
        at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3182)
        at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3176)
        at org.apache.crimson.parser.Parser2.resolveURI(Parser2.java:2758)
        at org.apache.crimson.parser.Parser2.maybeExternalID(Parser2.java:2730)
        at org.apache.crimson.parser.Parser2.maybeDoctypeDecl(Parser2.java:1129)

        at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:489)
        at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
        at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)

        at org.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl
.java:185)
        at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:76)
        at XMLParser.<init>(XMLParser.java:62)
        at DesktopFrame.actionPerformed(DesktopFrame.java:814)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
64)
        at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1817)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:419)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257
)
        at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
        at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1
109)
        at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseRelease
d(BasicMenuItemUI.java:943)
        at java.awt.Component.processMouseEvent(Component.java:5093)
        at java.awt.Component.processEvent(Component.java:4890)
        at java.awt.Container.processEvent(Container.java:1566)
        at java.awt.Component.dispatchEventImpl(Component.java:3598)
        at java.awt.Container.dispatchEventImpl(Container.java:1623)
        at java.awt.Component.dispatchEvent(Component.java:3439)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450
)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)

        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
        at java.awt.Container.dispatchEventImpl(Container.java:1609)
        at java.awt.Window.dispatchEventImpl(Window.java:1585)
        at java.awt.Component.dispatchEvent(Component.java:3439)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:197)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:150)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
java.lang.NullPointerException
        at XMLParser.getSymbols(XMLParser.java:157)
        at DesktopFrame.actionPerformed(DesktopFrame.java:815)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
64)
        at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1817)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:419)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257
)
        at javax.swing.AbstractButton.doClick(AbstractButton.java:289)
        at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1
109)
        at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseRelease
d(BasicMenuItemUI.java:943)
        at java.awt.Component.processMouseEvent(Component.java:5093)
        at java.awt.Component.processEvent(Component.java:4890)
        at java.awt.Container.processEvent(Container.java:1566)
        at java.awt.Component.dispatchEventImpl(Component.java:3598)
        at java.awt.Container.dispatchEventImpl(Container.java:1623)
        at java.awt.Component.dispatchEvent(Component.java:3439)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450
)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)

        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
        at java.awt.Container.dispatchEventImpl(Container.java:1609)
        at java.awt.Window.dispatchEventImpl(Window.java:1585)
        at java.awt.Component.dispatchEvent(Component.java:3439)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:197)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:150)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
0
 
LVL 35

Accepted Solution

by:
girionis earned 320 total points
ID: 8097915
 It expects the location of the dtd file under the relative URI of your application. Try to use an absolute URI by doing:

  <!DOCTYPE symbolDefinition SYSTEM "file://C/symbol.dtd">

  and tell us what happens. Your SAX implementation parser should be able to resolve it this time.
0
 

Author Comment

by:asukai
ID: 8098084
Isn't it
<!DOCTYPE symbolDefinition SYSTEM "file://C:/symbol.dtd">

?
0
 
LVL 35

Expert Comment

by:girionis
ID: 8098306
 Hmm... I think it is without the ":". Try it with both and see if it works.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question