Xerces question

hi all,
i wanted to know how to get the attribute 'width' from the following tag:
<svg width="382" height="966" viewBox="0 0 382 966" xml:space="preserve">
also, i have an error(Exception in thread "main" java.lang.NoSuchMethodError: main ) when i tried to run my app even though i dont have any errors when compiling.
please help. thank you
the following is just a testing code(it does simple stuff):
import org.w3c.dom.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.*;
import org.xml.sax.*;
import java.io.*;
import java.io.File;
public class getImageAttribute
     public getImageAttribute()
          String txt;
          Document doc;
          Element imageElement;
          try
               DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
               DocumentBuilder builder = factory.newDocumentBuilder();
               doc = builder.parse("d:\\project\\svg\\temp.svg");
               Element root = doc.getDocumentElement();
               imageElement = (Element)root.getElementsByTagName("image").item(0);
               txt = imageElement.getAttribute("xlink:href");
               System.out.println(txt);
          catch (ParserConfigurationException ioe)
               ioe.printStackTrace();
          catch (SAXException sax)
               sax.printStackTrace();
          catch (IOException io)
               io.printStackTrace();
}

You get a runtime error, because you're trying to execute a main routine in a class that doesn't have any (any Java beginner's book would help).
For accessing the data in your attributes try the following:
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NamedNodeMap;
import org.xml.sax.SAXException;
public class JAXPDOMTest{
   public void domParse(String url)
      DocumentBuilder parser;
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      factory.setValidating(true);
      try {
         parser = factory.newDocumentBuilder();
         Document doc = parser.parse(url);
         Node svg = doc.getElementsByTagName("svg").item(0);
         if(svg!=null)
            NamedNodeMap nnmap = svg.getAttributes();
            if(nnmap!=null)
               int n=nnmap.getLength();
               for(int i=0;i<n;++i)
                  Node node=nnmap.item(i);
                  System.out.println("attibute("+node.getNodeName()+")="+node.getNodeValue());
            else
               System.out.println("NamedNodeMap =null");
         else
            System.out.println("Node svg=null");
      } catch (Exception e) {
         e.printStackTrace();
   static public void main(String[] args)
      JAXPDOMTest x=new JAXPDOMTest2();
      x.domParse("test.xml");
}Here's the simple test.xml I tried:
<?xml version="1.0"?>
<svg width="382" height="966" viewBox="0 0 382 966" xml:space="preserve"/>Take a look at this thread:
http://forums.java.sun.com/thread.jsp?forum=34&thread=151897
Hope that helps.

Similar Messages

  • Question About Xerces Parser and Java  JAXP

    Hi,
    I have confusion about both of these API Xerces Parser and Java JAXP ,
    Please tell me both are used for same purpose like parsing xml document and one is by Apache and one is by sun ?
    And both can parse in SAX, or DOM model ?
    Is there any difference in performane if i use xerces in my program rather then JAXP, or is ther any other glance at all.
    Please suggest some thing i have and xml document and i want to parse it.
    Thanks

    Hi
    Xerces is Apaches implementation of W3C Dom specifiacation.
    JAXP is a API for XML parsing its not implementation.
    Sun ships a default implementation for JAXP.
    you have factory methods for selecting a parser at run time or you can set in some config file about what is the implementaion class for the SAXParser is to be chosen (typically you give give the class file of xerces sax parser or dom parser etc..)
    go to IBM Developerworks site and serch for Xerces parser config. which have a good explination of how to do it.
    and browse through j2ee api .may find how to do it.

  • Xerces - SAX - ContentHandler question

    hi,
    I am just trying to work out how to get at variables with a registered and set ContentHandler after the parsing process.
    e.g.
    XMLReader reader = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
    ContentHandler contentHandler = new CustomContentHandler();
    reader.setContentHandler(contentHandler);If I had a method inside my customerHandler,
      public boolean getFlag(){
        return flag;
      }i would have thought this may work but does not,
    XMLReader reader = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
    ContentHandler contentHandler = new CustomContentHandler();
    reader.setContentHandler(contentHandler);
    ContentHandler handler = reader.getContentHandler();
    if(handler.getFlag()){
    ....process
    }else{
      ....do something else
    }is something like this possible.
    I know all logic can go in the handler, but acn this be done?
    jp.

    ahhh!!!
    I probably would have got round to thinking to do that,
    I tried CustomerContentHandler handler = (ContentHandler)reader.getContentHandler();
    the reason I want to do it this way was just to keep logic native to the xml processing in the Handler, and then send a msg back to the web service client, depending on what went on in the handler, for example,
    public class MyWebService{
      XMLReader reader = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
    ContentHandler contentHandler = new CustomContentHandler();
    reader.setContentHandler(contentHandler);
    reader.parse("my sax input source")
    CustomContentHandler handler = (CustomContentHandler) reader.getContentHandler();
    if(handler.getFlag()){
      build msg response
    }else{
       build other msg response
    return messageResponse;
    }I'm not sure if I could have send the messageResponse from within the ContentHandler ?

  • Please help: question about eclipse & xerces

    hi,
    i have eclipse 3.0 and am trying to get the xerces java package (ver 2.6.2) to work for it. i downloaded xerces from this link: http://www.apache.org/dist/xml/xerces-j/
    there are so many different files in there, i'm not entirely sure if you download everything or just one. anyway, the one i downloaded was the fourth one down, called xerces.j.bin.2.6.2.zip (5.6m in size).
    i've unzipped it, but am unsure how i go about configuring eclipse 3.0 so that i can import and make use of xerces in my java apps. could anyone who has experience with this please help me?
    thanks,
    ramsey

    it's OK guys, took me ages but i got it sorted.

  • More question on validating XML using schema on Xerces

    I have read previous posts. It seems that the XML file is validated before it is parsed to document.
    However, im my implementation, I need to modify the DOM tree, and i need to validate it when I append child to the current DOM tree. How can I achieve this?

    Dynamic voalidation is only supported by a DOM 3 Validation specification implementation.

  • Some questions on whitespace and &

    Dear all,
    I have some questions on whitespace and & that need you kind help:
    1. Except /n /t /r and space, is there any characters that are whiteSpace characters?
    2. When parsing XML document, when the ignorableWhitespace() method is called? Will it be called from characters() ?
    e.g. Where the white space after <a> is called, and where is the white space between test1 and test 2 indied <b> is called?
    <a>
       <b>test1 test2</b>
    </a>  3. When the & should be escaped in a well-formed (or validated) XML file by replacing &?
    It should be excaped in any element content, such as <b>test1 & test2< /b> - except for <![CDATA[ section?
    It should NOT always be used in attributes? e.g. <a b="test1 & test2"/>  - has to do escaped by entity & - am I right?
    Thanks!
    Thanks
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Thanks DrClap.
    >
    2. When parsing XML document, when the
    ignorableWhitespace() method is called? Will it be
    called from characters() ?It will be called when the document has a DTD and the
    parser is a validating one that is actually
    validating, when the parser sees whitespace that is
    not part of a DTD element. It will not be called from
    characters() because that is a method that you write.I wrote a contentHandler and using Xerces parser to parse an XML document. When I set validating feature to false, I found that for:
    <a>
       <b>test1 test2</b></a>The white space between <a> and <b> (including newline) is actually called from characters(), not in ignorableWhitespace(). So does this mean that if validating - white space is always called from ignorableWhitespace(), and if not validating, if it is always called from characters()?
    >
    3. When the & should be escaped in a well-formed(or
    validated) XML file by replacing &? The XML Recommendation says "The ampersand character
    (&) and the left angle bracket (<) may appear
    in their literal form only when used as markup
    delimiters, or within a comment, a processing
    instruction, or a CDATA section. If they are needed
    elsewhere, they must be escaped using either numeric
    character references or the strings "&" and
    "<" respectively."So in this sense, both & in <b>test1 & test2< /b> and <a b="test1 & test2"/> is illegal unless replacing them by & - right? What does the markup delimiters mena in above XML Recommendation ? Example?
    Thanks!

  • Extracting elements from an xml string - org.apache.xerces.dom.DeferredText

    Hello all,
    I am new to xml, and I thought I had a handle on things until I got this problem...I am getting an xml string from the body of an e-mail message, and then I am trying to extract elements out of it. Here is an example xml string:
    <?xml version="1.0" encoding="UTF-8"?>
    <filterRoot>
       <filter action="MOVE" bool="AND" name="My Saved Filter" target="Deleted Items">
          <condition attribute="TO" bool="AND" contains="CONTAINS">
             <value>[email protected]</value>
             <value>[email protected]</value>
             <value>[email protected]</value>
             <value>[email protected]</value>
             <value>[email protected]</value>
          </condition>
       </filter>
    </filterRoot>I am trying to extract the <filter> element out and store it into a Vector of Elements (called, not surprisingly, filters). However, I am getting a class cast exception:
    java.lang.ClassCastException: org.apache.xerces.dom.DeferredTextImplIt is being called from where I trying to extract the <filter> in this way:
            filterRoot = doc.getDocumentElement(); // get topmost element
            NodeList list = filterRoot.getChildNodes();
            Vector newFilters = new Vector();
            debug("There are "+list.getLength()+" filters in document");
            for(int i=0; i<list.getLength(); i++) {
                Node n = list.item(i);
                debug("Node "+i+" getNodeValue() is "+n.getNodeValue());
                Element temp = (Element)n;
                newFilters.add(temp);
            }Perhaps my question is, how do I correctly get hold of the <filter> node so that I may cast it as an Element?
    thanks,
    Riz

    Yes, I already knew that it is not a bug.
    But, I got next step problem.
    I put "false" to "include-ignorable-whitespace" feature in xerces parser.
    But, I still found unnecessary TextNodes in my parser object.
    Feature link : http://xerces.apache.org/xerces-j/features.html.
    I use xerces-2_8_0.
    DOMParser parser = new DOMParser();
    parser.setFeature("http://apache.org/xml/features/dom/include-ignorable-whitespace", false);
    parser.parse(inputSource);
    document = ps.getDocument();
    System.out.println(document.getDocumentElement().getChildNodes().length()); // still wrong lengthIs tehre any example of usage this feature?
    What is default defination of white-space "\n "(enter with one space) or " "(juz white space) or something else?
    Thanks,

  • General question about webservices

    I hava a file "Test.java" (which attempts to test a webservice) and a XML-File.
    I compiled the Test-class successfully and now I'm wondering what are the next
    steps to be able to send a request to the webservice and get a response.
    I know that I will need to install Apache Axis (?). But I have no idea how to go on.
    What is with the Test.class? I'll have to pack it somehow, I suppose.
    Sorry if my question's too stupid. I'm a beginner with Java and all those web- and xml-things are very confusing. :o(
    The Test.java:
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.net.URL;
    import java.security.Security;
    import org.apache.axis.Constants;
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import org.apache.axis.encoding.XMLType;
    import org.xml.sax.ContentHandler;
    import org.xml.sax.InputSource;
    import org.xml.sax.XMLReader;
    import org.xml.sax.helpers.XMLReaderFactory;
    import javax.xml.rpc.ParameterMode;
    public class Test
    public static void main(String [] args) throws Exception {
         try {
              runIt();
         } catch(Exception e) {
              e.printStackTrace();
    private static void runIt() throws Exception {
         System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
         Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
         System.setProperty("javax.net.ssl.trustStore","C:/java/olliclientkeystore");
         String ret = "";
         String endpoint = "https://whatever";
         Service service;
         Call call;
         for (int i = 0; i <= 8; i++) {
         switch(i) {
              case 0:     System.out.println("Case 0");
              service = new Service();
              call = (Call) service.createCall();
              call.setTargetEndpointAddress(new URL(endpoint));
              call.setOperationName("abc");
              call.addParameter("x1", Constants.XSD_STRING, ParameterMode.IN);
              call.addParameter("x2", Constants.XSD_STRING, ParameterMode.IN);
              call.addParameter("x3", Constants.XSD_STRING, ParameterMode.IN);
              call.addParameter("x4", Constants.XSD_INT, ParameterMode.IN);
              call.setReturnType( XMLType.XSD_STRING );
              call.setUsername("xyz");
              call.setPassword("zyx");
              ret = (String) call.invoke(new Object[] {"abc",null,null, new int[] {1,3,5}});
              break;
              case 1:     System.out.println("Case 1");
              case 8:     System.out.println("Case 8");
                        service = new Service();
                        call = (Call) service.createCall();
                        call.setTargetEndpointAddress(new URL(endpoint));
                        call.setOperationName("def");
                        call.setReturnType( XMLType.XSD_STRING );
                        call.setUsername("xyz");
                        call.setPassword("zyx");
                        ret = (String) call.invoke(new Object[] {});
                        break;
         //System.out.println(ret);
         File f = new File("C:\\AnyName"+i+".xml");
         if (f.exists() && f.canWrite()) {
              f.delete();
         try {
              FileWriter write = new FileWriter("C:\\Anyname"+i+".xml",true);
              write.write(ret);
              write.close();
         } catch(IOException e) {
              e.printStackTrace();
         try {
              XMLReader reader = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
              InputSource in = null;
              try {
                   in = new InputSource(new FileInputStream(f));
              } catch(FileNotFoundException e) {
                   System.out.println("Datei nicht gefunden oder Zugriff verweigert: "+f.toString());
              Parser parser = new Parser();
              ContentHandler xmlImp = parser;
              reader.setContentHandler(xmlImp);
              reader.parse(in);
         } catch(Exception e) {
              System.out.println("Fehler: ");
              e.printStackTrace();
    }Can anybody please give me a hint? (or a link to a very good tutorial which
    is understandable for a beginner like me)
    Thanks in advance.

    When I execute the class I get the following message:
    Case 0
    AxisFault
    faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
    faultSubcode:
    faultString: java.net.UnknownHostException: ollilap.hsh-berlin.com
    faultActor:
    faultNode:
    faultDetail:
         {http://xml.apache.org/axis/}stackTrace:java.net.UnknownHostException: ollilap.hsh-berlin.com
         at java.net.PlainSocketImpl.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(Unknown Source)
         at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:92)
         at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:181)
         at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:397)
         at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:135)
         at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
         at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
         at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
         at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
         at org.apache.axis.client.Call.invokeEngine(Call.java:2754)
         at org.apache.axis.client.Call.invoke(Call.java:2737)
         at org.apache.axis.client.Call.invoke(Call.java:2413)
         at org.apache.axis.client.Call.invoke(Call.java:2336)
         at org.apache.axis.client.Call.invoke(Call.java:1793)
         at Test.Test.runIt(Test.java:69)
         at Test.Test.main(Test.java:39)
         {http://xml.apache.org/axis/}hostname:Dell1
    java.net.UnknownHostException: ollilap.hsh-berlin.com
         at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
         at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
         at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
         at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
         at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
         at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
         at org.apache.axis.client.Call.invokeEngine(Call.java:2754)
         at org.apache.axis.client.Call.invoke(Call.java:2737)
         at org.apache.axis.client.Call.invoke(Call.java:2413)
         at org.apache.axis.client.Call.invoke(Call.java:2336)
         at org.apache.axis.client.Call.invoke(Call.java:1793)
         at Test.Test.runIt(Test.java:69)
         at Test.Test.main(Test.java:39)
    Caused by: java.net.UnknownHostException: ollilap.hsh-berlin.com
         at java.net.PlainSocketImpl.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(Unknown Source)
         at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:92)
         at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:181)
         at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:397)
         at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:135)
         ... 11 moreI execute it out of Eclipse. I think that that must be wrong (?).
    I created a *.war-file and tried to deploy it with Java Web Sevices Developer Pack
    DeployTool. But that doesn't work.

  • Using a new version of Xerces in Weblogic 7.0

    I have deployed Weblogic 7.0 and I notice that there are two different versions
    of xerces.jar, one in the server/lib directory and the other one in workshop/lib.
    The latter being the new version. If I use the default setting and if I use a
    standalone server then the parser is not able to do schema validation since it
    does not have the feature. This is because the startup script calls the xerces.jar
    in the 'server/lib' folder. If I replace that with the xerces.jar from the 'workshop'
    folder everything works fine. Here are my questions:
    1. Why are we using an old version of xerces.jar?
    2. Would replacing the xerces.jar file with the new version cause any problems?

    You can try resetting your iPad by simultaneously pressing and holding the Home and Sleep/Wake buttons until you see the Apple Logo. This can take up to 15 seconds so be patient and don't release the buttons until the logo appears.
    Try again to see if the problem persists.
    I recommend syncing to iTunes first as well as creating a backup - just in case something goes wrong.
    Then you can update your iPad. Go to Settings > General > Softwware Update to start the process.

  • Basic questions about XMP

    I am a recent convert to XMP. I guess I have seen the proverbial writing on the Adobe all.
    First, I would like to get some questions out of the way. It seems to me that PDF has been moving to full XML file format, beginning with two areas:
    - Custom attributes, aka custom attributes, aka metadata (this is the stuff that used to be saved in the "Info" dictionary).
    - Fillable fields, aka interactive fields, aka widgets
    Question 1: Is there any commonality between the 2 areas above? Can the XMP SDK toolkit be used only for metadata? What about the interactive fields? Will I need another SDK (which one?) to handle those?
    TIA,
    -RFH

    The next question is about XML parsers. Adobe decided to go with "Expat", at least for XMP. I am myself a fan of Xerces. Is there an XML parser attached (i.e., chosen by Adobe) to deal with the above mentioned fillable/interactive fields?
    Thanks,
    -Ramon

  • SAX parsers hanging (crimson and xerces) on InputStream

    Hi,
    While searching I've seen a lot of postings about sax parsers hanging on InputStreams. Many have no replies, some do. So far I've tried several fixes mentioned to no avail. I've seen it hang in the startDocument() and hang after reading the entire document. All sorts of hangs . . . Oh and in some situations it works fine, but that's not good enough.
    1. I tried wrapping the InputStream as described at the jdom.org FAQ with my own InputStream that hides the close() call. Then I pass my wrapper InputStream to the saxparser.parse() method. This didn't work, because you need to wrap SocketInputStream, not InputStream and SocketInputStream has package permissions which keep me from inheriting from it. If somebody can shed some light on how to do this, I'll try again, but for now that approach is shelved.
    2. I tried adding an EOF character, 0x1A, to the end of the xml string being sent over the socket. The parser still hangs.
    Any more suggestions?
    Thanks,
    Steve

    Here's a faq question and answer from jdom.org. Can anybody explain how to do this in more detail? He mentions two workarounds. I've done the second and it works fine, but I'd prefer to get the first workaround working instead -- the wrapper InputStream idea.
    Why does passing a document through a socket sometimes hang the parser?
    The problem is that several XML parsers close the input stream when they read EOF (-1). This is true of Xerces, which is JDOM's default parser. It is also true of Crimson. Unfortunately, closing a SocketInputStream closes the underlying SocketImpl, setting the file descriptor to null. The socket's output stream is useless after this, so your application will be unable to send a response. To workaround, protect your socket's input stream with an InputStream wrapper that doesn't close the underlying stream (override the close() method), or read everything into a buffer before handing off to the JDOM builder:
    byte[] buf = new byte[length];
    new DataInputStream(inputStream).readFully(buf);
    InputStream in = new ByteArrayInputStream(buf);
    (Contributed by Joseph Bowbeer)

  • Exception :Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found

    Hi All,
    I run my application on Redhat Linux 2.4.9-e.27smp using java appname. I'm using JDK1.4.2 and am not using any app server. The app seems to run just fine for a few hours and then I start getting Exception :Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found exception out of blue. I run the app with following parameters -
    java -server -XX:+UseAdaptiveSizePolicy -Xverify:none -Xms512m -Xmx512m -XX:+UseParallelGC -XX:ParallelGCThreads=4
    I suspect this has to do with garbage collection and can't replicate this on will. I wonder if anyone has come across similar issue and is able to point me to the right direction.
    Thanks for any help,
    Vishal Bhasin

    Quick question. I am receiving the following error too:
    Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found
    I am getting this error intermitently. Do you have any idea why this would happen. I am using an add on to a program.
    Thanks,
    Joe

  • Stop Xerces to resolve Entities

    Hi,
    1) Question:
    ============
    I've got the following problem. In one of my swing-projects i need the possiblity to edit XML-Code. Now when reading in the XML-File Xerces expands ENTITITES like &amp; and in my Swing-App only & is shown. I have not found a property or something like this to prevent Xerces from expanding the entities. Does anybody know how to do this?
    2) Question:
    ============
    At the moment I have solved the problem from above by using the xml-Parser which comes with java-1.4. It does not expand Entities when setting
    -----------------cut----------------------
    factory.setExpandEntityReferences( false );
    -----------------cut----------------------
    Now there's the problem. For some of the XML-Files I need Schema-Validation which could only be done by Xerces (am I right?). Still at the moment when I add the xercesImpl.jar to my classpath the sun-parser does not resolve entities any more. Does anybody know what's going on there?
    thx
    tom

    XML does not allow & by itself to appear in a text node. The rule is that it must be escaped, i.e. you must put &amp; when you want that ampersand character. That rule, however, only specifies how the ampersand character must appear when it is in an XML file. When it is extracted from the XML file by software, Xerces or other, it will be treated as an ampersand.
    So that's the rule. Presumably what you said about "expanding entities" was a confusion of that rule, but I couldn't really tell.
    Anyway, what your Swing app should display for the ampersand character depends on what it is designed to display. If you are just putting raw XML into a text box and allowing the user to edit it, then you should put valid XML there, and that means the escaped version (&amp;). But I wouldn't recommend that approach, because humans are likely to violate XML rules, like the escaping rule for example and many others. You are likely to end up with malformed XML if you do that.
    However, if you have something like a tree structure with an element or an attribute at each node, then you should certainly display the unescaped version (&). This is what you will get when you extract a text node from a DOM anyway, and it's a correct representation of what is actually in the XML file from the user's point of view.
    That's how you should treat the ampersand character, in my view. But the escaped ampersand character is normally not considered to be an entity. If you are declaring it as an entity in your schema, perhaps you should not do that as it seems to be leading to a lot of confusion.

  • Question about document/literal web service

    Hello every body.
    I have some question about document/literal web service.
    I’ve been working with Axis before.
    Axis has four valid signatures for your message-style service methods:
    public Element [] method(Element [] bodies);
    public SOAPBodyElement [] method (SOAPBodyElement [] bodies);
    public Document method(Document body);
    public void method(SOAPEnvelope req, SOAPEnvelope resp);
    The same I am trying to do with WebLogic API for webservices.
    But when I am trying to test web service (public Document method (Document body); )
    I have serialized exceptions for org.w3c.dom.Document.
    Do I have to write a custom class for org.w3c.dom.Document serialization?
    If yes can you give me some idea or example?
    The all idea behind this web service is. I have just one web service and mane classes for XML processing. Depends what xml document will be during runtime, web service will be using different class for xml processing. It works fine with Axis, but in case of WebLogic I have some problem.
    One more question… How I have to call this web service from java client?
    I have seen this example http://www.manojc.com/?sample31 ,
    but this web service looks like (Document helloDom()). I need to send Document.
    This example works for Dynamic Proxy, but does not work for static call.
    Any ideas?? Thank in advance.

    Hi,
    I am getting a similar issue. I created a Document-style/literal webservice and deployed on Weblogic 9.2 . Then I generated client stubs using clientgen. I get the following exception stack trace:
    java.rmi.RemoteException: web service invoke failed: javax.xml.soap.SOAPException:
    failed to serialize class java.lang.Objectweblogic.xml.schema.binding.SerializationException: type mapping lookup failure on
    class=class com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl TypeMapping=TYPEMAPPING SIZE=3
    ENTRY 1:
    class: java.lang.Object
    xsd_type: ['http://xmlns.ozarkexpress.com/business/sell']:stns:echoDocumentResponse
    ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@1125127
    deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@18dfef8
    ENTRY 2:
    class: java.lang.Object
    xsd_type: ['http://xmlns.ozarkexpress.com/business/sell']:stns:echoDocument
    ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@15e83f9
    deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@2a5330
    ENTRY 3:
    class: java.lang.Object
    xsd_type: ['http://www.w3.org/2001/XMLSchema']:xsd:anyType
    ser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@bb7465
    deser: weblogic.xml.schema.binding.internal.builtin.XSDAnyCodec@d6c16c

  • EJB 30 begginner question

    I am trying to write a simple program to populate a table through entity beans using ejb30 with annotations. Being a begginner my question could be completely idiotic, please bear with me :)
    I am using toplink as my persistence provider and i get this stracktrace
    INFO: Hibernate EntityManager 3.3.1.GA
    javax.persistence.PersistenceException: No Persistence provider for EntityManager named FormStorePersistenceService: Provider named oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider threw unexpected exception at create EntityManagerFactory:
    oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
    Local Exception Stack:
    Exception [TOPLINK-30005] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
    Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@a39137
    Internal Exception: java.lang.NullPointerException
         at oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:143)
         at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:169)
         at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:110)
         at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
         at com.spireline.fs.appserver.kernel.businessprocess.formsservice.FormStoreImplTest.testFormPersistenceService(FormStoreImplTest.java:39)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
         at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
         at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
         at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
         at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
         at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
         at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
         at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
         at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
         at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
         at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
         at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
         at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
         at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    Caused by: java.lang.NullPointerException
         at java.util.Hashtable.put(Unknown Source)
         at java.util.Properties.setProperty(Unknown Source)
         at oracle.toplink.essentials.internal.ejb.cmp3.xml.parser.PersistenceContentHandler.startElement(PersistenceContentHandler.java:111)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
         at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.processPersistenceXML(PersistenceUnitProcessor.java:151)
         at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.processPersistenceArchive(PersistenceUnitProcessor.java:99)
         at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.getPersistenceUnits(PersistenceUnitProcessor.java:89)
         at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initPersistenceUnits(JavaSECMPInitializer.java:236)
         at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initialize(JavaSECMPInitializer.java:255)
         at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:155)
         ... 25 more
    Provider named oracle.toplink.essentials.PersistenceProvider threw unexpected exception at create EntityManagerFactory:
    oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
    Local Exception Stack:
    Exception [TOPLINK-30005] (Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException
    Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@a39137
    Internal Exception: java.lang.NullPointerException
         at oracle.toplink.essentials.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:143)
         at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:169)
         at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:110)
         at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
         at com.spireline.fs.appserver.kernel.businessprocess.formsservice.FormStoreImplTest.testFormPersistenceService(FormStoreImplTest.java:39)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
         at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
         at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
         at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
         at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
         at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
         at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
         at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
         at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
         at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
         at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
         at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
         at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
         at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    Caused by: java.lang.NullPointerException
         at java.util.Hashtable.put(Unknown Source)
         at java.util.Properties.setProperty(Unknown Source)
         at oracle.toplink.essentials.internal.ejb.cmp3.xml.parser.PersistenceContentHandler.startElement(PersistenceContentHandler.java:111)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
         at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.processPersistenceXML(PersistenceUnitProcessor.java:151)
         at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.processPersistenceArchive(PersistenceUnitProcessor.java:99)
         at oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor.getPersistenceUnits(PersistenceUnitProcessor.java:89)
         at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initPersistenceUnits(JavaSECMPInitializer.java:236)
         at oracle.toplink.essentials.internal.ejb.cmp3.JavaSECMPInitializer.initialize(JavaSECMPInitializer.java:255)
         at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createEntityManagerFactory(EntityManagerFactoryProvider.java:155)
         ... 25 more
    The following providers:
    org.hibernate.ejb.HibernatePersistence
    Returned null to createEntityManagerFactory.
         at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:154)
         at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
         at com.spireline.fs.appserver.kernel.businessprocess.formsservice.FormStoreImplTest.testFormPersistenceService(FormStoreImplTest.java:39)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
         at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
         at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
         at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
         at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
         at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
         at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
         at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
         at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
         at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
         at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
         at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
         at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
         at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    my persistence.xml is in the classes/META-INF directory("classes" directory is in the classpath).My persistence.xml is shown below.
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
         <persistence-unit name ="FormStorePersistenceService" transaction-type="RESOURCE_LOCAL">
              <class>com.spireline.fs.appserver.kernel.dao.publication.Publication</class>
              <provider>oracle.toplink.essentials.PersistenceProvider</provider>
              <properties>
         <property name="toplink.jdbc.driver">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
         <property name="toplink.jdbc.password">narsi40</property>
         <property name="toplink.jdbc.username">narsi40</property>
         <property name="toplink.jdbc.url">jdbc:sqlserver://testdb:1433;databaseName=narsi40</property>
         </properties>
         </persistence-unit>
    </persistence>
    It looks like the processes throws a nullpointerexception when it is parsing the above persistence.xml file and for the life of me i can't understand why !!!?
    Also i am bit baffled that it is trying to look for hibernate classes as it does specifiy
    *"org.hibernate.ejb.HibernatePersistence" as its provider, even though i have specified toplink as the provider in the persistence.xml. Can somebody explain what is happening here.*
    Thanks in advance
    Narsi

    I have already tried to google smack it..with no luck of course. Will post this in the hibernate forum.
    Thanks
    Narsi

Maybe you are looking for

  • MacBook Pro to LCD LG tv

    Dear Common Wisdom: Hi! what is the best way to use my new LG LCD tv with my MacBook Pro? i would like to use it to show pictures, presentations and watch movies- Thanks! KT

  • Error trying to add "International Freedom" Add-on...

    Hello, I'm trying to add "International Freedom" Add-onn but everytime I try I'm getting the same error: Your Calling Plan can't be displayed or changed online as the phone number you've entered isn't a BT residential line. I'm not a business as my l

  • How can I retain the local user name when using imported network tags?

    I am using network tags that have been imported from a remote DSC module 6.1 application. I would like to retain the remote user in the tag records instead of whoever is logged in locally. Is this possible?

  • REST and FLICKR

    I've been trying to figure out how to pull images from FLICKR (or even if I can) Taking my own site as an example: http://www.flickr.com/photos/barbbowman/ If I display the source for that page and look for XML, I find the two feeds near the bottom o

  • How to make the listener auto start with OS?

    Using: 10gR2 (10.2.0.3) RAC +ASM 64bit  &  11g Gateway (11.1.0.7) 64bit 2 Node Cluster Platform: SUSE Linux Enterprise Server 8 (x86_64) (kernel: 2.6.5-7.276-smp) I have a two node cluster that uses a 10gR2 DB home. I have setup a 11g Gateway home to