DOM(XML) + StyledDocuments

Hi there,
I wonder how one could adapt the structure of DOM-Documents to the structure StyledDocuments are made up.
What I want to do is the following:
I want to parse a XML file by using DOM. The I want the DOM-Object (containing the parsed XML-file) to be displayed in a JTextPane, and I want to be able to specify for each tag what it should look like in the TextPane (color, font,...).
Does anyone have an idea how to realize this? I am grateful to any help.
Sincerely
Karlheinz Toni

Hi Karlheiz Toni,
you would have to build your own mapper between a DOM document and a Java document which would convert from a DOM document to a Java document.
Another option would be to build an own DOMEditorKit with a ViewFactory and Views built to render DOM documents for JTextPane directly.
And a third solution would be to parse the XML file directly into a Java document instead of a DOM document.
But all solutions would involve quite a lot effort and as far as I have seen nothing exists for that so far.
Ulrich

Similar Messages

  • Does PHP 5.1.2 that comes shipped with OAS 10.1.3.4.0 support DOM/XML?

    Hello,
    We have installed OAS 10.1.3.0. PatchSet 10.1.3.4.0. It comes with PHP4 by default and the Oracle HTTP Server. We did the necessary instructions from Metalink and the README on how to enable PHP5. We can bring up Apache with no issues and phpinfo shows PHP 5.1.2. However, the DOM/XML is not enabled in this bundled PHP that came with OAS. Is DOM/XML supported? Is there an Oracle product that bundles PHP that supports DOM/XML? Thanks.

    You would have to make sure the extension is enabled when you build PHP yourself.
    "Installing OCI8 with Oracle Application Server on Linux" in the 2008 edition of http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf has some notes on installing PHP on AS.

  • DOM XML parser program

    Hi,
    I am trying to write a sample program using DOM xml parser in java to read the values in a XML file.
    please suggest me what are all the things I have to do for that.
    I know Java and XML. I want to know how to access values from XML file in java.
    Thanks
    Selvakumar

    Study up on the javax.xml.parsers API here at Sun. Next, download Xerces from Apache (xml.apache.org). Finally, take a tutorial.
    - Saish

  • Installing a DOM XML Parser

    Hey, I apologize for the newbie question but I suppose this is as good a place as any for it. I'm in desperate need of a DOM XML parser and have decided upon the Apache parser, "Xerces," featured here. My problem is this, every time I make a move towards installing it, I get all mixed up at the mention of my "Apache, ant and forrest" installations that I am apparently supposed to have in order for this library to work. My question is, is this library only for use in web-based applications and thus requires Apache in order to run? I ask because the application I'm working on is simply for desktop usage and the users it will be distributed to will not have Apache installations. If somebody could help me out with a quick little walk-through on the installation of this library it would be IMMENSELY appreciated.
    Edited by: Tracekill on Sep 13, 2009 11:01 AM

    Study up on the javax.xml.parsers API here at Sun. Next, download Xerces from Apache (xml.apache.org). Finally, take a tutorial.
    - Saish

  • Question about DOM XML

    Hi Experts
    Do you Know how can I write I DOM XML
    the header of file I Mean
    <?xml version="1.0" encoding="iso-8859-8"?>
    Regards
    Yossi

    hi,
    say u have xml with following structure
    <xml>
    <Age>xyz</Age>
    </xml>
    to append age node, parse the xml string or file and try the following code
    HERE DOM is used
    Document xmlDoc = wdThis.ParseFile(xmlString);
    Node root=xmlDoc.getDocumentElement();
    Node AgeNode = xmlDoc.createElement("Age");
    Node AgeTextNode = xmlDoc.createTextNode("25");
    AgeNode.appendChild(AgeTextNode);
    root.appendChild(AgeNode);
    following code to parse the xml string
    public org.w3c.dom.Document mParseFile( java.lang.String XmlString )
    //@@begin mParseFile()
    //pearse the xml string passed
    IWDMessageManager mesg = wdComponentAPI.getMessageManager();
    String l_method = "mParseFile";
    //parsing xml string to xml document
    ByteArrayInputStream l_xmlDataInputStream = new ByteArrayInputStream(p_XmlString.getBytes());
    Document l_doc = null;
    InputSource in = new InputSource((InputStream) l_xmlDataInputStream );
    DocumentBuilderFactory l_dbf = DocumentBuilderFactory.newInstance();
    l_dbf.setValidating(true);
    l_dbf.setNamespaceAware(true);
    DocumentBuilder l_db;
    try {
    l_db = l_dbf.newDocumentBuilder();
    l_doc = l_db.parse(in);
    catch (ParserConfigurationException e) {
    } catch (SAXException e) {
    } catch (IOException e) {
    //returns xml document
    return l_doc;

  • DOM, XML Schema, Java.  Confused!!!

    Hi all,
    Please help me to answer the 3 questions. I'm totally confused.
    1. Does DOM allow us to add invalid data based on the XML schema?
    2. I have an XML file. I want to use DOM to add, modify and delete nodes from the file, then print out an XML output file. If DOM does not prevent us from adding invalid data, I guess we have to run the validation after the output file is printed out?
    3. There are so many parsers, DOM, ... outthere that I am totally confused. Please give me your suggestions. I want to use Java to populate the DOM tree, check the data integrity based on the XML schema as I modify the DOM tree (if possible) or after printing the XML output to a file. What parser should I use? What DOM should I use (DOM or JDOM)? Can I use MS XML parser (because that what my main client uses), DOM, and Java? If so what do I need. I have read 2 books and many sites, but still don't have the answer clear yet.
    Very appreciate your help,
    Nam.

    1.
    never tried with Schema, with DTD: yes
    2.
    it is what I did*, which is pretty clumsy: currently AmauryDebou has started another thread on this subject but there's no answer yet.
    *in fact I do everything in RAM (no file needed): I ouptut the DOM in a byte array and then reparse it
    3.
    Xalan/Xerces is pretty standard (they are used in JAXP).
    JDOM has a reputation of being faster than DOM - depends on the amount of data you deal with.
    if you develop in Java, forget MSXML
    if parsing speed is an issue, you can achieve excellent performances with James Clark's XP.

  • DOM xml file, reading

    I have an XML file I am parsing, or trying to parse. I can get the Document object but how do you traverse the elements?? It seems simple but the Node methods are somewhat vague in what they return, per the Javadoc. I've tried trial and error to much frustration and very little success...
    is there an easy way to traverse the xml elements in a DOM Document object? I'm using the org.w3c package for most of what I'm doing...
    I'm sure this is just a few lines of code but it's been driving me crazy.

    from the document you would do,,
    Element e = document.getDocumentElement();
    From there you have two choices, you can navigate strictly via the tree with, calls of
    Element child = e.getFirstChild();
    while (child != null)
    //do something
    child = child.getNextSibling();
    or you can collect all the Elements that have a certain tag, as in
    NodeList list = e.getElementsByTagName( "MyElementName" );

  • DOM XML creation

    Hi Experts,
    I want to create a XML file representing the orgainzation structure tree in HR by Creating a DOM tree using the standard classes and methods. I am refereing to the following link
    http://help.sap.com/saphelp_nw04/Helpdata/EN/86/8280db12d511d5991b00508b6b8b11/frameset.htm
    CAn any one share abap code or example related to this?
    Thanks and Regards,
    SHilpa Dhawan

    Is there any chance that you have came across with [this document|http://help.sap.com/saphelp_nw04/Helpdata/EN/86/8280d212d511d5991b00508b6b8b11/content.htm]?
    Cheers

  • DOM XML Parser in Stateless Session Bean- Not able to generate Container

    I am trying to do some XML Parsing using a DOM Parser in a Stateless Session Bean. I am importing org.apache.xerces.parsers.DOMParser and trying the following statement DOMParser parser = new DOMParser();
    Even though I am able to compile and generate the initial jar file. When I try to generate the container using the Weblogic Deployer GUI tool, the process keeps on going(I mean that I see the small window saying Container Generating working) and it never stops.
    Any suggestions are welcome.

    Many thanks ksaks for replying.
    Actually day before yesterday we were able to do something like this. But then I kept this thread open only to see if experts have some good way of doing this.
    What I mean is if this way is industry standards in terms of design and does it follow the most popular way how experts do it?
    I am asking this as WebProjects have webcontent/web-inf directory wherein we put those xsds and property files, but we do not have anything like this in an EJB project. so was just wondering if this is the correct way of doing it or not.
    I am still following this approach because I had to proceed further in my development. Confirmation would erase any other doubts on this.
    Hope you find time to reply.
    Kind Regards,
    user2205
    Edited by: user2205 on Nov 10, 2008 11:43 PM

  • Dom - XML Error

    Hi,
    i have a big problem...
    When i transform my document object to a xml object following message
    is thrown:
    Only a default namespace can have an empty URI. Error processing resource 'http://squid.cis.cs.tu-berlin.de:8000/NEX/NESearchResult.jsp?query=rkerte'. Line 29, Position 773
    <?xml version="1.0" encoding="UTF-8"?><rdf:RDF xmlns:NS0="http://nutria.cs.tu-berlin.de/roodolf/rdfs#" xmlns:lom-life="http://ltsc.ieee.org/2002/09/lom-lifecycle#" xmlns:lom-edu="http://ltsc.ieee.org/2002/09/lom-educational#" xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#" xmlns:NS1="http://purl.org/dc/elements/1.1/#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:lom-tech="http://ltsc.ieee.org/2002/09/lom-technical#" xmlns:neweco="http://nutria.cs.tu-berlin.de/NE/rdfs#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:lom="http://ltsc.ieee.org/2002/09/lom-base#" xmlns="">
    <rdf:Description xmlns:rdf="" rdf:about="http://fert.dwd.de">
    <NS0:cachedSize xmlns:NS0="">5k</NS0:cachedSize>
    <NS0:relatedInformationPresent xmlns:NS0="">
    true
    <dc:description xmlns:dc="">
    Chief rkerte TEST
    </dc:description><dc:title xmlns:dc="">
    Homepage of rkerte TEST
    </dc:title><dc:subject xmlns:dc="">
    In java:
    org.w3c.dom.Document outputDocument = roodolfFactory.newDocumentBuilder().newDocument();
    Element root = outputDocument.createElement("rdf:RDF");
    root.setAttribute("xmlns:rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
    root.setAttribute("xmlns:rdfs", "http://www.w3.org/2000/01/rdf-schema#");
    root.setAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/");
    root.setAttribute("xmlns:dcterms", "http://purl.org/dc/terms/");
    root.setAttribute("xmlns:vCard", "http://www.w3.org/2001/vcard-rdf/3.0#");
    root.setAttribute("xmlns:lom-life", "http://ltsc.ieee.org/2002/09/lom-lifecycle#");
    root.setAttribute("xmlns:lom-edu", "http://ltsc.ieee.org/2002/09/lom-educational#");
    root.setAttribute("xmlns:lom-tech", "http://ltsc.ieee.org/2002/09/lom-technical#");
    root.setAttribute("xmlns:lom", "http://ltsc.ieee.org/2002/09/lom-base#");
    root.setAttribute("xmlns:neweco", "http://nutria.cs.tu-berlin.de/NE/rdfs#");
    root.setAttribute("xmlns:NS0", "http://nutria.cs.tu-berlin.de/roodolf/rdfs#");
    root.setAttribute("xmlns:NS1", "http://purl.org/dc/elements/1.1/#");
    I already tried: root.setAttribute("xmlns", "http://....");
    The I create the childs an append it to the root!
    Can someone help me?
    Greetings connan

    I already tried: root.setAttribute("xmlns", "http://....");
    What you need to add to the root is not an attribute, but a namespace. Unfortunately the DOM design doesn't deal with namespaces very well. Look for methods like setAttributeNS instead of setAttribute. You'll probably find that you can't declare the namespace in the root element, but you have to set it on every attribute you add. (Although I could be wrong about this... if I'm correct, you can still produce an equivalent XML document that repeatedly declares the namespace in every element.)

  • DOM - XML File

    Hi,
    Another question I had is pretty simple, and I'm sure it's documented somewhere, but I can't seem to find it.
    If I have parsed an XML file using DOM (thus have a master context), how do I write the DOM back to an XML file?
    Thanks,
    Mark

    print() method on XMLDocument.
    e.g. to Print the document to
    a printwriter do:
    myDocument.print(myPrintWriter);
    If myDocument is of type "Document" (DOM)
    then you need to cast it to XMLDocument:
    ((XMLDocument)myDocument).print(myPrintWriter);
    since printing functionality is not specified in the core DOM interfaces.

  • Validating a Dom XML tree

    Is there a solution to validate a XML document represented by a DOM Document ?
    The class DocumentBuilder let us validate a XML document but only when parsing XML file and not a DOM tree.
    In my program, I build an XML document using DOM (Node.appendChild(), ...); and I'd like, after having built it, to validate it. How can I do ?
    Thank's.

    Serialize it to some output format, making sure you include a reference to the DTD you want to validate against. Then read that output back into a validating parser.

  • Populating xmlclassgen classes from DOM/XML?

    Can I use an XML document or a DOM to populate
    classes generated by xmlclassgen (XML Class Generator for Java)?
    http://technet.oracle.com/tech/xml/classgen/section.htm says:
    "The generated Java source files can then be used to construct,
    optionally validate, and print a XML document that is
    compliant to the DTD specified"
    but is there anyway to import an XML document and access
    it through the API generated by xmlclassgen?
    Thanks
    Mats
    null

    Mats Strandberg (guest) wrote:
    : Can I use an XML document or a DOM to populate
    : classes generated by xmlclassgen (XML Class Generator for
    Java)?
    : http://technet.oracle.com/tech/xml/classgen/section.htm says:
    : "The generated Java source files can then be used to
    construct,
    : optionally validate, and print a XML document that is
    : compliant to the DTD specified"
    : but is there anyway to import an XML document and access
    : it through the API generated by xmlclassgen?
    : Thanks
    : Mats
    Are you asking for the class generator to handle something like
    xsl:import for the generated XML document to include?
    Currently, no such functionality exists, but it can be
    considered. Please describe in detail or pseudo code what
    you're trying to do.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    null

  • DOM xml white space in xml element

    Hi there
    Can anyone please help me out with a issue I'm having with altering an xml, and then storing it.
    The thing is, that when I delete all elements under a parent to insert something new there's a big gap when looking at the xml. Like this
    orginal xml fil(as an example):
    <batch>
    <somethingtag> <- Im removing these
    </somethingtag>
    <somethingtag> <- Im removing these
    </somethingtag>
    <somethingtag> <- Im removing these
    </somethingtag>
    <somethingtag> <- Im removing these
    </somethingtag>
    <somethingtag> <- Im removing these
    </somethingtag>
    </batch>
    with code:
              for(int i = 0; i < antallStartTagger ;i++)
                   //System.out.println("Slettet invoicetag nr: " + i);
                   Element startTag = (Element) nodeEn.item(0);                              // Forrige er slettet, s� neste f�rste hele tiden
                   startTag.getParentNode().removeChild(startTag);               
    don't bother the name. The result is:
    <batch>
    <- still space
    </batch>
    and when I insert a new element, it put itself at the far bottom, like this:
    <batch>
    <newtag>
    </newtag>
    <newtag>
    </newtag>
    </batch>
    And for saving the file STILL with gaps I use the Transformer class:
    File xmlOutputFile = new File(filename......);
         FileOutputStream fos = null;
         Transformer transformer = null;
                   fos = new FileOutputStream(xmlOutputFile);
                   // Use a Transformer for output
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
         transformer = transformerFactory.newTransformer();
              DOMSource source = new DOMSource(documentSkjellett);
              StreamResult result = new StreamResult(fos);
              // transform source into result will do save
         transformer.transform(source, result);
         ediLog.append(" -> [" + ediFil + "] lagret");
              catch (FileNotFoundException e)
              {System.out.println("##FEIL## : FileNotFoundException i lagreXMLFil: " + e.getMessage() + " " + e);}
              catch (TransformerConfigurationException e)
              {System.out.println("##FEIL## : TransformerConfigurationException i lagreXMLFil: " + e.getMessage() + " " + e);}
              catch (TransformerException e)
              {System.out.println("##FEIL## : TransformerException i lagreXMLFil: " + e.getMessage() + " " + e);}
    Can anyone advice?
    Paul

    It's because <batch> has two types of children: elements and text nodes.
    Assuming that the text is just whitespace, and you don't care about any text occurring between nodes, first call document.normalize() to aggregate all that text into one big node, then seek out and destroy it.
    Alternately, if you know that there shouldn't be any text directly under <batch>, simply iterate through its child nodes and remove any that are instanceof Text.

  • DOM XML Parsing...

    Hi All,
    I need a sample code to parse the following xml...
    <EMPLOYEE>
    <RECORD>
    <EMPID>12</EMPID>
    <EMPNAME>ROCK</EMPNAME>
    </RECORD>
    <RECORD>
    <EMPID>13</EMPID>
    <EMPNAME>PETER</EMPNAME>
    </RECORD>
    <RECORD>
    <EMPID>14</EMPID>
    <EMPNAME>JOHN</EMPNAME>
    </RECORD>
    </EMPLOYEE>
    I need a generic parser code, to parse the records and populate into employee table.
    Thanks in Advance....
    Regards,
    Simbhu

    One way is using supplied XML function
    SQL> create table my_employee ( empid number primary key, empname varchar2(50));
    Table created.
    SQL> insert into my_employee
    2 select extractValue(column_value, '/RECORD/EMPID') EMPID, extractValue(col
    umn_value, '/RECORD/EMPNAME') EMPNAME from TABLE(
    3 XMLSEQUENCE(
    4 EXTRACT(
    5 XMLTYPE(
    6 '<EMPLOYEE> <RECORD> <EMPID>12</EMPID> <EMPNAME>
    ROCK</EMPNAME></RECORD><RECORD><EMPID>13</EMPID><EMPNAME>PETER</EMPNAME></RECORD
    <RECORD><EMPID>14</EMPID><EMPNAME>JOHN</EMPNAME></RECORD></EMPLOYEE>'7 ),
    8 '/EMPLOYEE/RECORD'
    9 )
    10 )
    11 ) tb;
    3 rows created.
    SQL> select * from my_employee;
    EMPID EMPNAME
    12 ROCK
    13 PETER
    14 JOHN
    Better way is if you have XSD, register it into Oracle. Oracle will create underlying tables.
    Best Regards
    Erturk

Maybe you are looking for

  • Exchange rate field greyed out when i use custom PO order type

    Hi! Upon creation of PO using SAP standard order type NB, the field exhange rate is editable. While when i used csutom PO order type, it is greyed out. How can we edit this? Where is the configuration of the exchange rate per order type? If this is c

  • Strange bug -- adding one more button OR page causes Form warning to appear

    I'm building a simple interactive document in InDesign CS4 on the Mac, to be exported/delivered as a PDF. There are a few text-based buttons on the Master Page that are set to Go To a Text Anchor on Release. There are 4 buttons of these buttons on th

  • How do i get permission from Apple to do my youtube tutorials?

    I do music tutorials using Logic Pro 8. I have just become a youtube partner. I have approx 75 vids all very similar fashion to each other. The problem is only 20 of the video tutorials were accepted into the revenue sharing partner program. I have a

  • Solution Manager 3.2 upgrade to version 7.0

    Hello All, I am in the Solution Manager 3.2 upgrade to version 7.0. In phase IS_SELECT "Upgrade Assistant" asks to add a few files update components (Attachment: screens). Two of them (ST-SER and CPRXRPM) I managed to find and read. However, in the S

  • Problem calling COM Object on Windows Server 2008 x64

    Hi, We are using 32 bits COM object called in Coldfusion page on 32 bits OS. It works fine since few years. Now we need to use it on x64 Windows Server 2008 and 64bits IIS. As I 've seen (http://www.coldfusionjedi.com/forums/messages.cfm?threadid=878