Write & Modify XML Document on Midlet

please help me, how to write & modify xml document on Midlet????
I use KXML1.2 but it can't do write & modify. I read this documentation.... KXML just only read XML document....
so everybody can help me.....
please send your comment on my email... because my internet bandwith is so low. It's long time when I open this forum.
thanks very much

Check out with kXML 2
Cheers,
Rohan Chandane

Similar Messages

  • How to write an xml Document to a flat file using JAVA....

    Can any one help me out.....
    How to write a XML Document to the current filesystem using JAVA....
    without using com.sun.xml.tree.*....
    Document xmlDoc;
         Node rows = (Node) xmlDoc.createElement("ROWS");
    xmlDoc.appendChild(rows);
    and i have to write this xmlDoc to a file called(abc.xml) for further use...

    Have you considered using JDOM? ( www.jdom.org )
    The XMLOutputter class can write the Document to a file. ( The Document however will be an org.jdom.Document object ).
    If you are weary of a new API, you could just create a new File object called abc.xml and stream the data from the XML Document you have to this new File object.

  • UCCX Modifying XML document in repository programatically

    Hi,
    I'm trying to write a web application that so that our non-admin users can have the ability to add holidays, turn on outage messages etc. The files that I need to manipulate are XML files that reside in the document repository.
    I had originally planned on placing the XML files on a remote web server and then have the uccx scripts reference the XML files like http://servername/holidaydates.xml and I would just have the program that I write manipulate the xml files accordingly.
    When I ran this past one of our consultants they said that this would add a lot of complexity. I'm not sure what he's talking about since I had it working in about 30 minutes.
    Anyways, I thought that another method that might be good is if I could download the xml files from the document repository, modify them locally, and then upload them. That way there isn't a web server in the mix.
    Is there a way to programatically download/upload files to the document repository?
    Thanks!

    I figured out what the issue was with my scipt and I have resolved it.

  • XML document in HTTP response

    Hello,
    I try to write a portal component, that provides an XML document. The component must be reachable via a URL. It generates an XML document from portal content. The generated XML document must be available using the URL.
    I tried to solve this by implementing an AbstractPortalComponent iView. Inside the doContent method I write the XML document into the IPortalComponentResponse. The problem is, that the response does not only include the XML document, but the XML data is included inside an HTML document. I already set the EPCFLevel in component-profile to 0. So there is very few JavaScript left inside the HTML document. But I don't want any HTML at all. I want only the pure XML document inside the HTTP response.
    Does anybody know a way to make a plain XML document available at an URL?
    Thanks, best regards, Oliver

    Try something like this in the docontent method
    HttpServletResponse resp = request.getServletResponse(true);
    resp.setContentType("text/xml");
    resp.getOutputStream().write(bytes);

  • Modifying XML files with JDOM

    Hi:
    I've been trying to get up to speed with JDOM, and while it seems pretty intuitive, I've been having a problem w/ modifying XML documents.
    Namely, once I get a Document object from a (skeleton) XML file, do changes made to the Document object through, say, addContent() propagate to the original file? My gut feeling is no, although this was certainly what I had expected initially.
    Here's a code fragment of what I had tried to do to populate a barebones XML file:
                   Document doc = builder.build(output);
              // add 100 elements, all the same
              for (int count = 0; count < 100; count++)
                   Element curr = new Element("book");
                   // create child nodes for book
                   Element title = new Element("title");
                   title.addContent("Book " + (count + 1));
                   Element author = new Element("author");
                   author.addContent("Author " + (count + 1));
                   Element price = new Element("price");
                   price.addContent("Price " + (count + 1));
                   curr.addContent(title);
                   curr.addContent(author);
                   curr.addContent(price);
                   doc.getRootElement().addContent( curr );
              }

    Mikael,
    This sounds like one of the many quirks (perhaps bugs) related to how FrameMaker handles non-FM files in books. The current book model doesn't play well with XML files as chapters and this seems like yet another problem. Apparently, if an xref does not target another .fm file in the book, Frame assumes that the target file is not in the book and therefore will not be in the book PDF.
    There have been discussions here about this in the past. The solution that I use is to run an API client before publishing that converts all XML files to .fm files, and redirect all xrefs appropriately. Then, book features work as expected and PDFs come out as normal. This is not feasible, however, without the automation from the API client.
    There may be some who would say that the best approach is to use XML and books the way that the designers did account for... that is, the whole book becomes an XML document with entity references to the separate chapters. In my work, though, this model was not appropriate... rather, I needed a binary FM book to act like a book, except with XML files as chapters. So, I think I understand your situation.
    Is API programming or FrameScript an option for you? I think it may be the only way to get what you are looking for.
    Russ

  • Writing XML Document to a file or the console

    How do i write an XML document to a file & to the console.
    Document doc = new Document
    doc = (Document)Class.forName("org.apache.xerces.dom.DocumentImpl").newInstance();
    Element root = doc.createElement("PERSON");
    Element item = doc.createElement("NAME");
    item.appendChild(doc.createTextNode("Vaskar"));
    root.appendChild(item);
    How do i write this doc object to the console

    if you use XMLDocument object which implements Document then you would be able to use the method print that is part of the xmlDocument class
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Vaskar Dasgupta ([email protected]):
    How do i write an XML document to a file & to the console.
    Document doc = new Document
    doc = (Document)Class.forName("org.apache.xerces.dom.DocumentImpl").newInstance();
    Element root = doc.createElement("PERSON");
    Element item = doc.createElement("NAME");
    item.appendChild(doc.createTextNode("Vaskar"));
    root.appendChild(item);
    How do i write this doc object to the console<HR></BLOCKQUOTE>
    null

  • Is there a way to modify the style sheet so that it transforms an XML document with empty tags as tag / ?

    I have extracted some code from codeproject to
    reindent an XML document. Does anyone know how I can modify the stylesheet to make it so that the transform of an XML file will result in empty tags showing up as <tag /> instead of <tag></tag>?
    // http://www.codeproject.com/Articles/43309/How-to-create-a-simple-XML-file-using-MSXML-in-C
    MSXML2::IXMLDOMDocumentPtr FormatDOMDocument(MSXML2::IXMLDOMDocumentPtr pDoc)
    LPCSTR const static szStyleSheet =
    R"!(<?xml version="1.0" encoding="utf-8"?>)!"
    R"!(<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">)!"
    R"!( <xsl:output method="xml" indent="yes"/>)!"
    R"!( <xsl:template match="@* | node()">)!"
    R"!( <xsl:copy>)!"
    R"!( <xsl:apply-templates select="@* | node()"/>)!"
    R"!( </xsl:copy>)!"
    R"!( </xsl:template>)!"
    R"!(</xsl:stylesheet>)!";
    MSXML2::IXMLDOMDocumentPtr pXmlStyleSheet;
    pXmlStyleSheet.CreateInstance(__uuidof(MSXML2::DOMDocument60));
    pXmlStyleSheet->loadXML(szStyleSheet);
    MSXML2::IXMLDOMDocumentPtr pXmlFormattedDoc;
    pXmlFormattedDoc.CreateInstance(__uuidof(MSXML2::DOMDocument60));
    CComPtr<IDispatch> pDispatch;
    HRESULT hr = pXmlFormattedDoc->QueryInterface(IID_IDispatch, (void**)&pDispatch);
    if (SUCCEEDED(hr))
    _variant_t vtOutObject;
    vtOutObject.vt = VT_DISPATCH;
    vtOutObject.pdispVal = pDispatch;
    vtOutObject.pdispVal->AddRef();
    hr = pDoc->transformNodeToObject(pXmlStyleSheet, vtOutObject);
    //By default it is writing the encoding = UTF-16. Let us change the encoding to UTF-8
    // <?xml version="1.0" encoding="UTF-8"?>
    MSXML2::IXMLDOMNodePtr pXMLFirstChild = pXmlFormattedDoc->GetfirstChild();
    // A map of the a attributes (vesrsion, encoding) values (1.0, UTF-8) pair
    MSXML2::IXMLDOMNamedNodeMapPtr pXMLAttributeMap = pXMLFirstChild->Getattributes();
    MSXML2::IXMLDOMNodePtr pXMLEncodNode = pXMLAttributeMap->getNamedItem(_T("encoding"));
    pXMLEncodNode->PutnodeValue(_T("UTF-8")); //encoding = UTF-8
    return pXmlFormattedDoc;
    Or, if there is some other method for reindenting a MSXML2::IXMLDOMDocumentPtr object where I can specify how I want empty tags to be stored, that would be great too.  However, I don't want it to lose its status of an MSXML2::IXMLDOMDocumentPtr object.
     I.e. I would like to still perform operations on the result as if it was still an MSXML2::IXMLDOMDocumentPtr object.
    Thanks,
    A
    Adrian

    If anyone is interested, I got an answer on StackOverflow
    here.
    Adrian

  • How to write a string   as an XML Document

    I wrote a web service to receieve a string and then write as an XMl document . But In my writer.java program, I am not doing something right. Please let me know what I am doing wrong.
    Below is writer program:
    public class Writer
    public Writer()
    } public void WriteHabFile(String out, String fileName)
    XMLDocument doc = new XMLDocument();
    try
    XMLPrintDriver output=new XMLPrintDriver(new FileOutputStream(new File(fileName)));
    output.setEncoding("utf-8");
    output.printDocument(doc);
    output.close();
    catch (Exception e)
    System.out.println(e.toString());
    public void WriteLanFile(String out2, String fileName2)
    XMLDocument doc = new XMLDocument();
    try
    XMLPrintDriver output=new XMLPrintDriver(new FileOutputStream(new File(fileName2)));
    output.setEncoding("utf-8");
    output.printDocument(doc);
    output.close();
    catch (Exception e)
    System.out.println(e.toString());
    }

    The problems is that your XML document is not parsed.

  • Please help; how to write XML document with JSP?

    I try to write XML document with JSP...
    But I got wrong results everytime.
    The result is not XML file displayed in the browser,
    but HTML file.
    I even tried to use HTML special code for <, >, "
    but still display as HTML file not XML file.
    How to do this?
    Thanks in advance. I put my codes below.
    Sincerely,
    Ted.
    ================
    Here is code for the JSP (called stk.jsp):
    <%@ page contentType="text/xml" %>
    <%@ page import="bean.Stock" %>
    <jsp:useBean id="portfolio" class="bean.Portfolio" />
    <% java.util.Iterator pfolio = portfolio.getPortfolio();
    Stock stock = null; %>
    <?xml version="1.0" encoding="UTF-8"?>
    <portfolio>
    <% while (pfolio.hasNext())
    stock = (Stock) pfolio.next(); %>
    <stock>
    <symbol>
    <%=stock.getSymbol() %>
    </symbol>
    <name><%=stock.getName() %> </name>
    <price><%=stock.getPrice() %> </price>
    </stock>
    <% } %>
    </portfolio>
    =================
    Here is the code for bean.Stock:
    package bean;
    public class Stock implements java.io.Serializable
    String symbol, name;
    float price;
    public Stock(String symbol, String name, float price)
    this.symbol = symbol;
    this.name = name;
    this.price = price;
    public String getSymbol()
    return symbol;
    public String getName()
    return name;
    public float getPrice()
    return price;
    ===============
    And here is bean.Portfolio:
    package bean;
    import java.util.Iterator;
    import java.util.Vector;
    public class Portfolio implements java.io.Serializable
    private Vector portfolio = new Vector();
    public Portfolio()
    portfolio.addElement(new Stock("SUNW", "Sun Microsystem", 34.5f));
    portfolio.addElement(new Stock("HWP", "Hewlett Packard", 15.15f));
    portfolio.addElement(new Stock("AMCC", "Applied Micro Circuit Corp.", 101.35f));
    public Iterator getPortfolio()
    return portfolio.iterator();
    }

    Hi
    I'm not sure whta your query is but I tested your code as it is has been pasted and it seems to work fine. There is an XML output that I'm getting.
    Keep me posted.
    Good Luck!
    Eshwar Rao
    Developer Technical Support
    Sun microsystems
    http://www.sun.com/developers/support

  • Write xml document

    Hi,
    I want to write a xml with a java program.
    Now I don`t know what's the best way to do this.
    To write it in normal ascii is very much work.
    So I wanted to know if there's a better way.
    Thank you.

    javax.xml.transform.TransformerFactory
    javax.xml.transform.Transformer

  • How do I add (or insert) a node into an XML document with JSTL?

    Dear all,
    I am trying to use JSTL to store some data from a form into XML. However, I have read many articles in JSTL and only found that it can only be, as far as those articles are concerned, used to "read" data from XML files, but not "write" to them.
    Am I missing something in JSTL? Or, if I want to write to an XML file (e.g., insert a new node, or modify a node's data), will I have to write my own bean and then use <c:usebean />?
    Thanks very much in advance.
    Regards,
    Robert

    JSTL is not a programming language in and of itself. It is intended to help you to write scriptlet free JSPs.
    JSP pages (by one school of thought) are intended to function as the "View" in a Model-View-Controller architecture.
    Being a view, JSP pages should be able to look at things - but not touch.
    The standard pattern is to go to a servlet first, which invokes the logic, and then forwards to a JSP for rendering.
    Editing XML by adding new nodes etc etc is thus a function of the java code layer - servlet/action whatever you want to call it.
    Giving you the power to edit XML documents via JSTL (ie on a JSP page) takes away from purity of the MVC design.
    Hence why they don't provide the tags for manipulating XML, and only provide the database tags with a disclaimer that they should only be used for prototypes/trivial apps!
    JSTL is designed to replace scriptlet code on a JSP page.
    It can replace 99% of scriptlet code. The other 1% shouldn't be on the JSP in the first place :-)
    cheers,
    evnafets

  • XML document structures must start and end within the same entity

    Hi there,
    I'm working with a client/server application and using SaxParser for reading in xml. I get the SaxParserException: XML document structures must start and end within the same entity. I understand what that means, but it isn't applicable! The xml data being used is well-formed. I checked the well-formedness with Stylus Studio to make sure. Here's the data:
    <?xml version='1.0' encoding='UTF-8'?>
    <vcmessage>
         <vcsource>3</vcsource>
         <processevent>16</processevent>
         <shape>
              <llindex>0</llindex>
              <shapetype>9</shapetype>
              <shapeproperties>
                   <shapelocation>
                        <xcoord>54</xcoord>
                        <ycoord>184</ycoord>
                   </shapelocation>
                   <bounds>
                        <width>24</width>
                        <height>24</height>
                   </bounds>
                   <fgcolor>
                        <fgred>0</fgred>
                        <fggreen>0</fggreen>
                        <fgblue>0</fgblue>
                   </fgcolor>
                   <bgcolor>
                        <bgred>255</bgred>
                        <bggreen>255</bggreen>
                        <bgblue>255</bgblue>
                   </bgcolor>
                   <thickness>1</thickness>
                   <isfilled>false</isfilled>
              </shapeproperties>
         </shape>
    </vcmessage>The parser generally stops around the </bgcolor> tag.
    I'm using Eclypse as my IDE. I'm wondering if there's something wrong with it? Or maybe there's something wrong with the class I'm using for reading in the XML? Followng is the class.
    Please advise,
    Alan
    package vcclient;
    import java.io.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    import javax.xml.parsers.*;
    public class XMLDocumentReader extends DefaultHandler
      private VCClient client = null;
      private Writer out;
      private String lineEnd =  System.getProperty("line.separator");
      private boolean haveSourceType = false;
      private boolean haveUserName = false;
      private boolean haveMessage = false;
      private boolean haveProcessEvent = false;
      private boolean haveLinkedListIndex = false;
      private boolean haveOpeningShapePropertiesTag = false;
      private boolean haveShapeType = false;
      private boolean haveOpeningShapeLocationTag = false;
      private boolean haveShapeLocation = false;
      private boolean haveOpeningXCoordTag = false;
      private boolean haveOpeningYCoordTag = false;
      private boolean haveOpeningBoundsTag = false;
      private boolean haveBoundsWidth = false;
      private boolean haveBoundsHeight = false;
      private boolean haveOpeningFGColorTag = false;
      private boolean haveOpeningBGColorTag = false;
      private boolean haveOpeningThicknessTag = false;
      private boolean haveOpeningIsFilledTag = false;
      private boolean haveOpeningImageDataTag = false;
      private boolean haveOpeningTextDataTag = false;
      private boolean haveFGRed = false;
      private boolean haveFGGreen = false;
      private boolean haveFGBlue = false;
      private boolean haveBGRed = false;
      private boolean haveBGGreen = false;
      private boolean haveBGBlue = false;
      private boolean haveThickness = false;
      private boolean haveIsFilled = false;
      private boolean haveImageData = false;
      private boolean haveTextData = false;
      private VCMessage vcmessage = null;
      public XMLDocumentReader(VCClient value)
           client = value;
           vcmessage = new VCMessage();
      public VCMessage getVCMessage()
           return vcmessage;
      public boolean haveSourceType()
         return haveSourceType; 
      public boolean ParseXML(InputStream stream)
         boolean success = false;
         // Use the default (non-validating) parser
        SAXParserFactory factory = SAXParserFactory.newInstance();
        try
             // Set up output stream
            out = new OutputStreamWriter(System.out, "UTF-8");
            // Parse the input
            SAXParser saxParser = factory.newSAXParser();
            saxParser.parse( stream, this );
            success = true;
        catch (SAXParseException spe)
            // Error generated by the parser
            System.out.println("\n** Parsing error"
               + ", line " + spe.getLineNumber()
               + ", uri " + spe.getSystemId());
            System.out.println("   " + spe.getMessage() );
            // Unpack the delivered exception to get the exception it contains
            Exception  x = spe;
            if (spe.getException() != null)
                x = spe.getException();
            x.printStackTrace();
            return success;
        catch (SAXException sxe)
             // Error generated by this application
             // (or a parser-initialization error)
             Exception  x = sxe;
             if (sxe.getException() != null)
                 x = sxe.getException();
             x.printStackTrace();
             return success;
        catch (ParserConfigurationException pce)
            // Parser with specified options can't be built
            pce.printStackTrace();
            return success;
        catch (Throwable t)
             t.printStackTrace();
             return success;
        return success;
      public void startDocument()throws SAXException
          emit("<?xml version='1.0' encoding='UTF-8'?>");
          nl();
      public void endDocument()throws SAXException
          try {
              nl();
              out.flush();
          } catch (IOException e) {
              throw new SAXException("I/O error", e);
      public void startElement(String namespaceURI,
                               String lName, // local name
                               String qName, // qualified name
                               Attributes attrs)throws SAXException
          String eName = lName; // element name
          if (eName.equals(""))
             eName = qName; // namespaceAware = false
          emit("<"+eName);
          if (attrs != null) {
              for (int i = 0; i < attrs.getLength(); i++) {
                  String aName = attrs.getLocalName(i); // Attr name
                  if (aName.equals("")) aName = attrs.getQName(i);
                  emit(" ");
                  emit(aName + "=\"" + attrs.getValue(i) + "\"");
          emit(">");
          if(makeStartTag(eName).equals(Constants.OPENING_SHAPEPROPERTIES))
                haveOpeningShapePropertiesTag = true;
          else if(makeStartTag(eName).equals(Constants.OPENING_SHAPELOCATION))
              haveOpeningShapeLocationTag = true;
          else if(makeStartTag(eName).equals(Constants.OPENING_BOUNDS))
                haveOpeningBoundsTag = true;
          else if(makeStartTag(eName).equals(Constants.OPENING_FGCOLOR))
                 haveOpeningFGColorTag = true;
          else if(makeStartTag(eName).equals(Constants.OPENING_BGCOLOR))
              haveOpeningBGColorTag = true;
          else if(makeStartTag(eName).equals(Constants.OPENING_BGGREEN))
               System.out.println("See BGGreen");
          else if(makeStartTag(eName).equals(Constants.OPENING_BGBLUE))
               System.out.println("See BGBlue");
          else if(makeStartTag(eName).equals(Constants.OPENING_THICKNESS))
              haveOpeningThicknessTag = true;
          else if(makeStartTag(eName).equals(Constants.OPENING_ISFILLED))
              haveOpeningIsFilledTag = true;
          else if(makeStartTag(eName).equals(Constants.OPENING_IMAGEDATA))
              haveOpeningImageDataTag = true;
          else if(makeStartTag(eName).equals(Constants.OPENING_TEXTDATA))
              haveOpeningTextDataTag = true;
      public void endElement(String namespaceURI,
                             String sName, // simple name
                             String qName  // qualified name
                            )throws SAXException
           if(sName.equals("") && !qName.equals(""))
              sName = qName;
              emit("</"+sName+">");
           else
              emit("</"+sName+">");
           if(makeEndTag(sName).equals(Constants.CLOSING_SOURCE_TYPE))
              haveSourceType = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_USER))
              haveUserName = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_MESSAGE))
              haveMessage = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_PROCESSEVENT))
               haveProcessEvent = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_LINKEDLISTINDEX))
               haveLinkedListIndex = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_SHAPETYPE))
               haveShapeType = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_SHAPELOCATION))
                haveOpeningShapeLocationTag = false;
           else if(makeEndTag(sName).equals(Constants.CLOSING_WIDTH))
               haveBoundsWidth = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_HEIGHT))
               haveBoundsHeight = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_BOUNDS))
                haveOpeningBoundsTag = false;
           else if(makeEndTag(sName).equals(Constants.CLOSING_FGRED))
               haveFGRed = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_FGGREEN))
               haveFGGreen = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_FGBLUE))
               haveFGBlue = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_FGCOLOR))
                haveOpeningFGColorTag = false;
           else if(makeEndTag(sName).equals(Constants.CLOSING_BGRED))
               haveBGRed = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_BGGREEN))
             haveBGGreen = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_BGBLUE))
               System.out.println("See closing BGBlue");
               haveBGBlue = true;
           else if(makeEndTag(sName).equals(Constants.CLOSING_BGCOLOR))
                haveOpeningBGColorTag = false;
           else if(makeEndTag(sName).equals(Constants.CLOSING_THICKNESS))
               System.out.println("XMLDocumentReader: Step2");
                haveOpeningThicknessTag = false;
           else if(makeEndTag(sName).equals(Constants.CLOSING_ISFILLED))
               haveOpeningIsFilledTag = false;
           else if(makeEndTag(sName).equals(Constants.CLOSING_IMAGEDATA))
               haveOpeningImageDataTag = false;
           else if(makeEndTag(sName).equals(Constants.CLOSING_TEXTDATA))
               haveOpeningTextDataTag = false;
      private String makeStartTag(String tag_name)
           String start = "<";
           String end = ">";
           return start.concat(tag_name).concat(end);
      private String makeEndTag(String tag_name)
           String start = "</";
           String end = ">";
           return start.concat(tag_name).concat(end);
      public void characters(char buf[], int offset, int len)throws SAXException
           String s = new String(buf, offset, len);
          if(haveSourceType == false)
               if(vcmessage.getSourceType() == null)
                  try
                    if(s.equals(""))return;
                   int sourcetype = Integer.parseInt(s);
                   vcmessage.setSourceType(sourcetype);                            
                  catch(NumberFormatException nfe){}
          else if(vcmessage.getSourceType() == SourceType.CHAT_SOURCE)
            if(vcmessage.getSourceType() == SourceType.CHAT_SOURCE && haveUserName == false)
                 vcmessage.setUserName(s);          
            else if(vcmessage.getSourceType() == SourceType.CHAT_SOURCE && haveMessage == false)
               //When the parser encounters interpreted characters like: & or <,
               //then this method gets invoked more than once for the whole message.
               //Therefore, we need to concatonate each portion of the message.  The
               //following method call automatically concatonates.
               vcmessage.concatMessage(s);                    
          else if(vcmessage.getSourceType() == SourceType.WHITEBOARD_SOURCE)
               if(haveProcessEvent == false)
                 try
                   vcmessage.setProcessEvent(Integer.parseInt(s));
                 catch(NumberFormatException nfe){}
               else if(haveLinkedListIndex == false)
                    try
                       vcmessage.setLinkedListIndex(Integer.parseInt(s));
                     catch(NumberFormatException nfe){}
               else if(haveShapeType == false)
                    try
                       vcmessage.setShapeType(Integer.parseInt(s));
                     catch(NumberFormatException nfe){}
               if(haveOpeningShapePropertiesTag)
                    if(haveOpeningShapeLocationTag)
                         if(haveOpeningXCoordTag)
                              try
                                vcmessage.setXCoordinate(Integer.parseInt(s));
                              catch(NumberFormatException nfe){}
                         else if(haveOpeningYCoordTag)
                              try
                                vcmessage.setYCoordinate(Integer.parseInt(s));
                                //reset all flags for ShapeLocation, X and Y coordinates
                                haveOpeningXCoordTag = false;
                                haveOpeningYCoordTag = false;
                                //haveOpeningShapeLocationTag = false;
                              catch(NumberFormatException nfe){}
                    else if(haveOpeningBoundsTag)
                         if(haveBoundsWidth == false)
                              try
                                vcmessage.setBoundsWidth(Integer.parseInt(s));
                              catch(NumberFormatException nfe){}
                         else if(haveBoundsHeight == false)
                              try
                                vcmessage.setBoundsHeight(Integer.parseInt(s));
                                //reset flag
                                //haveOpeningBoundsTag = false;
                              catch(NumberFormatException nfe){}
                    else if(haveOpeningFGColorTag)
                         if(haveFGRed == false)
                              try
                                vcmessage.setFGRed(Integer.parseInt(s));                           
                              catch(NumberFormatException nfe){}
                         else if(haveFGGreen == false)
                              try
                                vcmessage.setFGGreen(Integer.parseInt(s));                           
                              catch(NumberFormatException nfe){}
                         else if(haveFGBlue == false)
                              try
                                vcmessage.setFGBlue(Integer.parseInt(s));
                                //reset flag
                                //haveOpeningFGColorTag = false;
                              catch(NumberFormatException nfe){}
                    else if(haveOpeningBGColorTag)
                         if(haveBGRed == false)
                              try
                                vcmessage.setBGRed(Integer.parseInt(s));                           
                              catch(NumberFormatException nfe){}
                         else if(haveBGGreen == false)
                              try
                                vcmessage.setBGGreen(Integer.parseInt(s));                           
                              catch(NumberFormatException nfe){}
                         else if(haveBGBlue == false)
                         {   System.out.println("getting BGBlue data");
                              try
                                vcmessage.setBGBlue(Integer.parseInt(s));
                                //reset flag
                                //haveOpeningBGColorTag = false;
                              catch(NumberFormatException nfe){}
                    else if(haveOpeningThicknessTag)
                         try
                            vcmessage.setThickness(Integer.parseInt(s));                       
                          catch(NumberFormatException nfe){}
                    else if(haveOpeningIsFilledTag)
                         vcmessage.setIsFilled(s);
                    else if(haveOpeningImageDataTag && vcmessage.getProcessEvent() == org.jcanvas.comm.ProcessEvent.MODIFY)
                         vcmessage.setBase64ImageData(s);                    
                    else if(haveOpeningTextDataTag && vcmessage.getProcessEvent() == org.jcanvas.comm.ProcessEvent.MODIFY)
                         vcmessage.setTextData(s);
                    //reset
                    haveOpeningShapePropertiesTag = false;
          emit(s);
      //===========================================================
      // Utility Methods ...
      //===========================================================
      // Wrap I/O exceptions in SAX exceptions, to
      // suit handler signature requirements
      private void emit(String s)throws SAXException
          try {
              out.write(s);
              out.flush();
          } catch (IOException e) {
              throw new SAXException("I/O error", e);
      // Start a new line
      private void nl()throws SAXException
          try {
              out.write(lineEnd);
          } catch (IOException e) {
              throw new SAXException("I/O error", e);
      //treat validation errors as fatal
      public void error(SAXParseException e)
      throws SAXParseException
        throw e;
      // dump warnings too
      public void warning(SAXParseException err)
      throws SAXParseException
        System.out.println("** Warning"
            + ", line " + err.getLineNumber()
            + ", uri " + err.getSystemId());
        System.out.println("   " + err.getMessage());
    }

    Just out of curiosity what happens if you append a space to the end of the XML document?

  • ? is shown for Norwegian characters when XML document is parsed using DOM

    Hi,
    I've a sample program that creates a XML document with a single element book having Norwegian characters. Encoding is UTF-8. When i parse the XML document and try to access the value of that element then ? are shown for Norwegian characters. XML document file name is "Sample.xml"
                DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
                DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
                Document doc = docBuilder.newDocument();
                Element root = doc.createElement("root");
                root.setAttribute("value", "Á á &#260; &#261; ä É é &#280;");
                doc.appendChild(root);
                TransformerFactory transfac = TransformerFactory.newInstance();
                Transformer trans = transfac.newTransformer();
                trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
                trans.setOutputProperty(OutputKeys.INDENT, "yes");
                trans.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
                //create string from xml tree
                java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
                StreamResult result = new StreamResult(baos);
                DOMSource source = new DOMSource(doc);
                trans.transform(source, result);
                writeToFile("Sample.xml", baos.toByteArray());
                InputSource is = new InputSource(new java.io.ByteArrayInputStream(readFile("Sample.xml")));
                is.setEncoding("UTF-8");
                DocumentBuilder obj_db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
                Document obj_doc = obj_db.parse(is);
                obj_doc.normalize();
                System.out.println("Value is : " + new String(((Element) obj_doc.getElementsByTagName("root").item(0)).getAttribute("value").getBytes()));writeFile() - Writes the document bytes in Sample.xml file
    readFile() - Reads the Sample.xml file
    When i run this program XML editor shows the characters correctly but Java code output is: Á á ? ? ä É é ?
    What's the problematic area in my java code. I didn't get any help from any source. Please suggest me the solution of this problem.
    Thanx in advance.

    Hi,
    I'm using JBuilder 2005 and i mentioned encoding UTF-8 for saving Java source files and also for compilation. I've modified my source code also. But the problem persists. After applying changing the dumped sample.xml file doesn't display these characters correctly in IE, but earlier it was displaying it correctly at IE.
    Modified code is:
    DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
                DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
                Document doc = docBuilder.newDocument();
                Element root = doc.createElement("root");
                root.setAttribute("value", "Á á &#260; &#261; ä É é &#280;");
                doc.appendChild(root);
                OutputFormat output = new OutputFormat(doc, "UTF-8", true);
                java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
                OutputStreamWriter osw = new OutputStreamWriter(baos, "UTF-8");
                XMLSerializer s = new XMLSerializer(osw, output);
                s.asDOMSerializer();
                s.serialize(doc);
                writeToFile("Sample5.xml", baos.toByteArray());
                InputSource o = new InputSource(new java.io.ByteArrayInputStream(readFile("Sample5.xml")));
                o.setEncoding("UTF-8");
                com.sun.org.apache.xerces.internal.parsers.DOMParser obj_parser = new com.sun.org.apache.xerces.internal.parsers.DOMParser();
                obj_parser.parse(o);
                Document obj_doc = obj_parser.getDocument();
                System.out.println("Value : " + new String(((Element) obj_doc.getElementsByTagName("root").item(0)).getAttribute("value").getBytes()));I'm hanged on this issue. Can u please provide me the code snippet that works with these characters or suggest solution.
    Thanx

  • Can I append an XML Document into another?

    I have a large xml document which I open into coldfusion (mx
    7), and then a smaller group of files that are opened into thier
    own xml objects. After some customization of xml text values, I
    want to append the smaller xml documents into the larger document
    at specific positions within the document tree.
    I have the code that I thought would do this, using an
    arrayappend function, but what happens is that only the root
    element of the smaller (inserted) xml document is placed into the
    main document.
    Is this possible, or do I need to modify the code so that the
    entire tree of xml data that I am appending is created on the
    fly?

    Personally I do this with XSLT.
    <cfxml variable="doc1">
    <root>
    <member id="10">
    <name>Ian</name>
    <sex>male</sex>
    </member>
    </root>
    </cfxml>
    <cfxml variable="doc2">
    <root>
    <member id="1">
    <name>Joe</name>
    <sex>male</sex>
    </member>
    <member id="2">
    <name>John</name>
    <sex>male</sex>
    </member>
    <member id="3">
    <name>Sue</name>
    <sex>female</sex>
    </member>
    </root>
    </cfxml>
    <cffile action="write" file="#expandPath("/")#\doc2.xml"
    output="#ToString(doc2)#" nameconflict="overwrite">
    <!--- METHOD ONE using a depreciated and undocumented
    method --->
    <cfset newNode = doc1.root.member.cloneNode(true)>
    <cfset doc2.changeNodeOwner(newNode)>
    <cfset doc2.root.appendChild(newNode)>
    <cfdump var="#doc2#" label="Merged by hidden functions"
    expand="no">
    <!--- METHOD TWO using XSLT --->
    <!--- create an xsl docutment--->
    <cfoutput>
    <cfsavecontent variable="transformer">
    <xsl:stylesheet xmlns:xsl="
    http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:output method="xml"/>
    <!--load the merge file -->
    <xsl:variable name="emps"
    select="document('#expandPath("/")#\doc2.xml')"/>
    <!--- this line references and XML file to be combined
    with the main file,
    I wonder if there is a way to use an XML document in memory
    here? --->
    <!-- combine the files -->
    <xsl:template match="/">
    <root>
    <!-- select all the child nodes of the root tag in the
    main file -->
    <xsl:for-each select="root/child::*">
    <!-- copy the member tag -->
    <xsl:copy-of select="."/>
    </xsl:for-each>
    <!-- and all the child nodes of the root tag in the merge
    file -->
    <xsl:for-each select="$emps/root/child::*">
    <!-- copy the member tag -->
    <xsl:copy-of select="."/>
    </xsl:for-each>
    </root>
    </xsl:template>
    </xsl:stylesheet>
    </cfsavecontent>
    </cfoutput>
    <!--- create a combined xml document --->
    <cfset doc2 = XMLparse(XMLtransform(doc1,transformer))>
    <cfdump var="#doc2#" label="Merged by XSLT"
    expand="no">

  • Large XML Document Error

    We are using Oracle's XSQL servlet engine 9.0.2.0.0A to query an Oracle Database using xsql:include-owa. This xsql document uses a custom serializer to write the resulting XML to a file on the webserver. We have run into a problem with writing XML documents larger than approximatly 7MB. The file is written but just contains a Malformed XML Document error. We have tried tracking down the problem and it seems to be occuring before the custom serializer is given control of the document. Attached below is the xsql document and the Java source of our serializer if it would be of any help.
    -Eric Dalquist
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="simple_transform_xml.xsl" serializer="XMLWriter"?>
    <BASE_TAG connection="XXXXXXXX" xmlns:xsql="urn:oracle-xsql">
        <xsql:set-page-param name="save-file" value="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/applInfo.xml"/>
        <xsql:include-owa >
            STUDEV.STUADMSDSET.P_GET_RECRUIT_INFO('A','C');
        </xsql:include-owa>
    </BASE_TAG>-----------------------------------------
    * Author:        Eric Dalquist
    * E-Mail:        [email protected]
    * Date Created:  10-03-2001
    * Last Modified: 10-03-2001
    * Modified By:   Eric Dalquist
    * Description:   This class writes out the contents of the final document produced by the xsql servlet.
    package com.mtu.XSQLSerializers;
    import java.io.FileOutputStream;
    import oracle.xml.xsql.*;
    import oracle.xml.parser.v2.XMLDocument;
    import org.w3c.dom.Document;
    * <P>
    *    XMLWriter is an implementation of the abstract XSQLDocumentSerializer class. It is passed a refrence to a DOM Document
    *    and the servlet environment. The XMLWriter takes the document and writes it out to the servlet's output stream. There
    *    is also the option that the saveFile xsql page parameter can be set to a fully qualified path and file name to write the
    *    document to.
    * </P>
    * <P>
    *    Here is an example of setting the saveFile page paramter. This line would be the first tag inside the root xsql servlet tag.
    * </P>
    * <PRE>
    *    &#060;xsql:set-page-param name="save-file" value="/u01/oracle/ias10210/xdk/java/xsql/Repository/Course_List/XMLDocument.xml"/&#062;
    * </PRE>
    * @author  Eric B. Dalquist
    * @version 1.0 10/03/2001
    public class XMLWriter implements XSQLDocumentSerializer
        /** the header we send if we are returning XML */
        private static final String MIME_XML = "text/xml";
        /** the name of the page parameter we look for to get the path and name to save the XML document to */
        private static final String ATTR_FILE = "save-file";
         * The serialize is called by the servlet engine and is passed the DOM Docuement result
         * from the XSLT transformation if there was one and a refrence to the XSQL servlet environment
         * @param doc The document representation of the XML output of the xsql servlet.
         * @param env A refrence to the servlet's environment.
         * @throws Throwable Any unhandled error is handled by the servlet by default.
        public void serialize(Document doc, XSQLPageRequest env) throws Throwable
            System.out.print("start ... ");
            FileOutputStream fos = null;
            String reqType = env.getRequestType();
            String saveFile = env.getParameter(ATTR_FILE);
            if (!reqType.equals("Command Line"))
                env.setContentType(MIME_XML);
                ((XMLDocument)doc).print(env.getOutputStream());
                env.getOutputStream().close();
            if (saveFile != null && !saveFile.equals("") && saveFile.indexOf("..") == -1 && saveFile.indexOf("~") == -1)
                fos = new FileOutputStream(saveFile);
                ((XMLDocument)doc).print(fos);
                fos.close();
            System.gc();
            System.out.println("end");
    }

    Technically DBMS_XMLSAVE and it's alter ego DBMS_XMLQUERY are not considered part of XML DB. DBMS_XMLSAVE and DBMS_XMLQUERY are legacy Java implementations.
    In 9.2.x these routines were replaced by DBMS_XMLSTORE and DBMS_XMLGEN which are written in 'C' and should be much faster in most cases and address a number of limitations inherant in the older implementations. DBMS_XMLSTORE and DBMS_XMLGEN are part of XML DB and the minimum supported release for XML DB is 9.2.0.3.0.
    DBMS_XMLSAVE issues are addressed in the TECH/XML forum
    http://forums.oracle.com/forums/category.jspa?categoryID=51

Maybe you are looking for

  • HT4915 i no longer have my pc that was enabled for my iphone.

    i only use my iphone and want to delete songs, podcasts, and videos. Can i do this through my iphone? or, do i have to reset my iphone and delete everything on it?

  • TV Requirements?

    Hi! In looking at the TV requirements below I am unfamiliar with the terminalogy given by Apple and don't remember seeing such specs when looking at new tvs. I've been holding off buying a widescreen lcd but Apple TV now interests me but I'm afraid I

  • Recording from input jack

    can GB record analog and convert to AIFF using the input jack hooked up to (analog) tape deck? I've hooked up the deck and get a meter reading in Preferences , but don't know which program to record it with. If not GB is there another?

  • Items that are expensed immediately but have to track the quantity.

    Hi Experts! How do I set-up the item when the item should be expensed immediately but the quantity of the item needs to be monitored? Do I set it up as inventory or non-inventory item?   Your inputs are highly appreciated. Warm regards, Jen

  • Custom Preference Panel for quick access

    I love that I can hit CMD-K to get to preferences and toggle things like Scale Strokes & Effects. But that's pretty much the only one I toggle in that area. Request: A custom control panel (keyboard shortcut accessible) so I can quickly access freque