Generic xml writer

We have a new client that we need to send multiple xml file's to and I want to create a generic xml writer so I can pass in the data along with mapping document an be able to create the nodes off of the mapping document, I hope this makes sense, so if anyone has any examples or can point me in the right direction I would appreciate it

thevig wrote:
can point me in the right directionDesign first. Program and test next. Ask questions here if you have specific problems.

Similar Messages

  • Generic XML Parser for PL/SQL

    Is there a generic XML parser written in PL/SQL that does not
    rely on java that will run against a 7.3.4 database?
    If please let me know where I can locate it.
    Thanks,
    Tim
    null

    Tim (guest) wrote:
    : Is there a generic XML parser written in PL/SQL that does not
    : rely on java that will run against a 7.3.4 database?
    : If please let me know where I can locate it.
    : Thanks,
    : Tim
    There is not one currently but there are plans to provide the
    PL/SQL one on top of our C version. You can also check out the
    PLXML Utilities that have a limited version.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    null

  • How to export string in CDATA with the jaxb xml writer?

    How to export string in CDATA with the jaxb xml writer?
    It read CDATA no problem but it is lost on write.

    Found it:
    ### THIS WORKS WITH SUN JAXB REFERENCE IMPLEMENTATION. ###
    (Not tested with any other)
    In the xsd, you must create a type for your string-like element.
    Then associate a data type converter class to this new type, which will produce CDATA tags.
    Then you must set a custom characterEscapeHandler to avoid the default xml escaping in order to preserve the previously produced CDATA tag.
    Good luck.
    -----type converter-----
    import javax.xml.bind.DatatypeConverter;
    public class ExpressionConverter {
         * Convert an expression from an XML file into an internal representation. JAXB will
         * probably have already stripped off the CDATA encapsulation. As a result, this method
         * simply invokes the JAXB type conversion for strings but does not take any other action.
         * @param text an XML-compliant expression
         * @return a pure string expression
         public static String parse(String text) {
              String result = DatatypeConverter.parseString(text);
              return result;
         * Convert an expression from its internal representation to an XML-compliant version.
         * This method will simply surround the string in a CDATA block and return the result.
         * @param text a pure string expression
         * @return the expression encapsulated within a CDATA block
         public static String print(String text) {
              StringBuffer sb = new StringBuffer(text.length() + 20); //should add the length of the CDATA tags + 8 EOLs to be safe
              sb.append("<![CDATA[");
              sb.append(wrapLines(text, 80));
              sb.append("]]>");
              return DatatypeConverter.printString(sb.toString());
         * Provides line-wrapping for long text strings. EOL indicators are inserted at
         * word boundaries once a specified line-length has been exceeded.
         * @param text the string to be wrapped
         * @param lineLength the maximum number of characters that should be included in a single line
         * @return the new string with appropriate EOL insertions
         private static String wrapLines(String text, int lineLength) {
              //wrap logic, watchout for quoted strings!!!!
              return text;
    ------in caller----
    Marshaller writer = ......
    writer.setProperty("com.sun.xml.bind.characterEscapeHandler", new NoCharacterEscapeHandler());
    -----escaper-----
    import java.io.IOException;
    import java.io.Writer;
    import com.sun.xml.bind.marshaller.CharacterEscapeHandler;
    public class NoCharacterEscapeHandler implements CharacterEscapeHandler {
         * Escape characters inside the buffer and send the output to the writer.
         * @param buf buffer of characters to be encoded
         * @param start the index position of the first character that should be encoded
         * @param len the number of characters that should be encoded
         * @param isAttValue true, if the buffer represents an XML tag attribute
         * @param out the output stream
         * @throws IOException if the writing process fails
         public void escape(char[] buf, int start, int len, boolean isAttValue, Writer out) throws IOException {
              for (int i = start; i < start + len; i++) {
                   char ch = buf;
                   if (isAttValue) {
                        // isAttValue is set to true when the marshaller is processing
                        // attribute values. Inside attribute values, there are more
                        // things you need to escape, usually.
                        if (ch == '&') {
                             out.write("&");
                        } else if (ch == '>') {
                             out.write(">");
                        } else if (ch == '<') {
                             out.write("<");
                        } else if (ch == '"') {
                             out.write(""");
                        } else if (ch == '\'') {
                             out.write("&apos;");
                        } else if (ch > 0x7F) {
                             // escape everything above ASCII to &#xXXXX;
                             out.write("&#x");
                             out.write(Integer.toHexString(ch));
                             out.write(";");
                        } else {
                             out.write(ch);
                   } else {
                        out.write(ch);
              return;

  • Strip off markups of generic XML data with E4X

    I have a generic XML file:
    <nodes>
    <node1 att1='abc' att2='xyz'>
    <ele1> Hello </ele1>
    <ele2> Hi </ele2>
    </node1>
    </nodes>
    The tag and attribute names above can be anything. I need a
    generic method to strip off the XML markups and display the
    contents as:
    node1@att1: abc
    node1@att2: xyz
    node1.ele1: Hello
    node1.ele2: Hi
    How can E4X do this?

    e4x is for manipulating/navigating your xml. But you can use
    it inside a for/each loop to look at your xml nodes and extract the
    strings without the xml tags using toString().
    Search the help docs for "XML type conversion" and see the
    toString() method in action.

  • Generic PDF writer.  Stopped working after installing Yosemite.

    Generic PDF Writer stopped working after installing Yosemite.  Can anyone help??

    Yes, checked.  The system is up to date.

  • Using my XML writer?

    Hi, I'm trying to write an xml writer in order to save games in my chess program. The writer works fine, but I want to make a static or at least public instance of it I can use at different places. Ao I tried to put it here but it says...
    C:\Program Files\Xinox Software\JCreator LE\MyProjects\Exercises\Chess\ChessGame\GamePiece.java:11: unreported exception java.io.IOException; must be caught or declared to be thrown
         static XMLWriter xw = new XMLWriter("game.xml");
    ^
    1 error
    abstract class GamePiece extends Canvas
         static XMLWriter xw = new XMLWriter("game.xml");
    // other methods follow
    }I can get it to work by putting into the cunstructor of each child of GamePiece but I want just one running so that the different pieces can write to the same file when it's movePiece method is called.
    Here is the code for the XMLWriter
    import java.io.*;
    public class XMLWriter
         String file;
         FileWriter fw;
         BufferedWriter bw;
         PrintWriter outFile;
         public XMLWriter(String name) throws IOException
              file = name;
              fw = new FileWriter (file);
              bw = new BufferedWriter (fw);
              outFile = new PrintWriter (bw);
              outFile.print ("<?xml version= \"1.0\"?>\n\n");
              outFile.print ("<GAME>\n");
         public void addMove(int fromX, int fromY, int toX, int toY)
              outFile.print ("\t<MOVE>\n");
              outFile.print ("\t\t<FROM_X>" + fromX + "</FROM_X>\n");
              outFile.print ("\t\t<FROM_Y>" + fromY + "</FROM_Y>\n");
              outFile.print ("\t\t<TO_X>" + toX + "</TO_X>\n");
              outFile.print ("\t\t<TO_Y>" + toY + "</TO_Y>\n");
              outFile.print ("\t</MOVE>\n");
         public void endRecord()
              outFile.print ("</GAME>\n");
              outFile.close();
    }

    abstract class GamePiece extends Canvas
         static XMLWriter xw = new XMLWriter("game.xml");
    // other methods follow
    abstract class GamePiece extends Canvas {
      try {
        static XMLWriter xw = new XMLWriter("game.xml");
      } catch (IOException exc) { doSomethingAboutError(); }
    // other methods follow

  • Has anybody used XML Writer? There is a question.

    In XML Writer ,there is tow similar features, "Preview XML in Explorer" & "Transform XML with XSL".
    see my code :
    xml:
    <?xml version="1.0" encoding="gb2312"?>
    <?xml:stylesheet type="text/xsl" href="F:\&#25105;&#30340;&#24320;&#21457;&#39033;&#30446;\xml\XSL\&#20363;&#23376;\TestOutput03.xsl"?>
    <AAA>
      <BBB>bbb</BBB>
      <CCC>ccc</CCC>
    </AAA> xsl:
    <?xml version="1.0" encoding="gb2312"?>
    <xsl:stylesheet
         version="1.0"
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         xmlns="http://www.w3.org/TR/REC-html40">
        <xsl:output method = "xml" indent = "yes" />
              <xsl:attribute-set name = "set1" >
                   <xsl:attribute name = "a" >1</xsl:attribute>
                   <xsl:attribute name = "b" >2</xsl:attribute>
              </xsl:attribute-set>
              <xsl:attribute-set name = "set2" >
                   <xsl:attribute name = "cc" >33</xsl:attribute>
                   <xsl:attribute name = "dd" >44</xsl:attribute>
              </xsl:attribute-set>
              <xsl:template match = "/" >
                   <xsl:element name = "QQQ" use-attribute-sets = "set1 set2" >
                        <xsl:attribute name = "xxx" >555</xsl:attribute>
                   </xsl:element>
              </xsl:template>
    </xsl:stylesheet>When i preview the xml file in Explore(IE6), there is nothing.
    But when i use the "Transform xml with xsl". It showed:
    <?xml version="1.0"?>
    <QQQ a="1" b="2" cc="33" dd="44" xxx="555" xmlns="http://www.w3.org/TR/REC-html40" />
    Why?

    No, your XML file is just a text file. It can't do anything.
    You have two things that can do something. You know what they are because you asked about them. Now, I have no idea what this "XML Writer" thing is, but my guess is that "Preview XML in Explorer" gives the XML document to Internet Explorer, and it's supposed to find the XSL from that processing instruction in the XML. And since you don't provide it a valid URL, it doesn't find the XSL.
    Whereas "Transform XML with XSL" is given the XML file and the XSL file separately. So it can find the XSL, and therefore it works.
    That's just a guess. You're the one with whatever "XML Writer" is, you're going to have to look at it to see if I'm right.

  • A generic XML DTD

    Hi
         I am a newbie to XML and I have a question on XML/Java, hopefully, you guys would be able to give me some pointers to solve this problem.
         Here is the scenario. I need to design (might have to implement as well) a set of Java libraries that can retrieve data (basically, it's some kind of contents, it can be anything, more on this later) and base on the data I retrieved, I would generate a html file (which contains those contents and have the contents displayed).
         Those data (contents) I talked about earlier could be some news item, could be lottery results, could be a travel guide, could be anything. Those data would originally come from a XML file and then store into a database table. (or could just be in a file if there isn't much data). Either way, my programs should be able to read the data from the database/files and somehow "decrypt" it.
         Now, my problem is since the data could contain any kind of data, how do I define a DTD that is so generic that can treat all kinds of contents as the same. By that, I mean, e.g if it was a book review article, it might contain the book's name, the author, the review, the review date...etc, I would imagine that the DTD would contain tags like TITLE, AUTHOR, REVIEW DATE, REVIEW...etc. With all these data, they would be stored into a table, may be just a text field in that table. And then my programs would read from that field and break up those tags and display them accordingly (generate a html file) . But what if it is a lottery result, then the DTD that I defined earlier (for news) would not be applicable for the lottery result content. That means, in order to treat everything as just pure content, I can only have a tag, say content, and for the book review article, this tag would just wrap everything into itself (from the book's name, author....etc) and for the lottery results, the content tag would just contain the numbers. I must say, I have minimal XML knowledge, so please correct me if I am wrong here. But again, how would you define a DTD for such scenario? Is it possible to define such a DTD? Not to mention the style of the contents.......Please, I need help. THx
    ForeverJava
    anywhere else is a better place for XML forums?

    You certainly could water down a DTD to handle all of the different types of events that you are encountering. At this point though the DTD becomes so permissive that it is almost of no use.
    If you are using an XML parser to get at the data it will have to be well-formed. You might as well turn validation off, if the structure is so loose.
    Can you apply a different DTD based on the type of request that is coming back? For example if it's lotto results apply lotto.dtd if it's scores apply scores.dtd, etc.
    You could probably even wrap a root level around the entire document that is consistent and then require one of the data type (lotto, score, etc.) levels next and then proceed.
    Hopefully some of this makes sense-
    -Mike

  • Generic XML to SQL translator

    We are working on a project where we need to push blobs of XML data into a DB with an unknown schema. We are looking for a tool that defines it's own XML-to-SQL protocol that would allow it to accept XML data in a format known to it and then translate it into SQL statements to store the info. Our thought is to take the data in our "internal" XML format and supply an XSL document to translate to whatever the end schema is. So if we had this data:
    <MyDataObject>
    <Member1>foo</Member1>
    <Member2>bar</Member2>
    </MyDataObject>
    the XSL would translate it into a format that the tool would understand, like:
    <Table name=DataObjects>
    <Column name=Member1>foo</Column>
    <Column name=Member2>bar</Column>
    </Table>
    the tool would then know to create an INSERT statement to add this data to the DataObjects table. The key is that we don't know the name or setup of any of the tables or columns at compile time. These may vary at each installation. It's easy to provide a new XSL translation for each install. It's harder (i.e. not feasible) to write whole new classes to match each schema.
    The normal "XML to DB" tools/architectures like Castor, Torque, and JDOs don't seem to support this sort of dynamic binding to a DB. Does anyone know of a tool that does, or do we have to write our own?
    Thanks,
    Eric

    Why don't you translate the XML directly to an SQL statement or use XSL to generate the SQL?
    Franco

  • Sort generic XML document hierarchically ?

    Hi
    I need to sort entire xml alphabetically by node names.
    I.e. alphabetic sort by node names on first level, then alphabetic sort
    each node's children (second level), etc.
    The result will be same tree, but sorted alphabetically.
    I do not know names and structure beforehand, this is abstract XML document.
    Sorting can be applied either to text form , or DOM form (Document).
    Any Ideas ?
    Thanks !

    My idea would be to use the xsl:sort element ofXSLT.
    Thanks , but I can't figure out how to define such
    generic xsl:sort rule.
    All examples of this rule refers to tags by their
    name. And in my case tag name itself should be
    subject for sorting.Wouldn't that just be <xsl:sort select="name()">?
    In addition, this sorting should
    be performed on all levels of document , and depth is
    not known beforehand.So what? Put that in a template that's applied to every element. And make sure you call <xsl:apply-templates> in that template so it gets applied at all levels.

  • Persist XML Data to Database Table - Generic XML Schema

    Hi,
    I would like to represent data in XML format and persist to any database tables.
    The ideal xml is like:
    <TABLE NAME="TABLE1">
    <TABLEDEF><COLUMN NAME="COLUMN1"/><COLUMN NAME="COLUMN2"/></TABLEDEF>
    <ROW><COLUMN VALUE="value1"/><COLUMN VALUE="value2"/></ROW>
    <ROW><COLUMN VALUE="value11"/><COLUMN VALUE="value22"/></ROW>
    </TABLE>     
    <TABLE NAME="TABLE2">
    </TABLE>     
    The XML could then be parsed, and saved to database with JDBC by manually composing the statement strings.
    To reduce the coding effort (xml parsing, JDBC connection, etc), are there any open source projects available to achieve the above purpose? The popular O/R mapping tools like Hibernate, Castor, etc, can't handle this scanario because they require the knowledge of the tables on the server side in order to create the mapping files in advance.
    Thanks for the help!

    Hi,
    I would like to represent data in XML format and persist to any database tables.
    The ideal xml is like:
    <TABLE NAME="TABLE1">
    <TABLEDEF><COLUMN NAME="COLUMN1"/><COLUMN NAME="COLUMN2"/></TABLEDEF>
    <ROW><COLUMN VALUE="value1"/><COLUMN VALUE="value2"/></ROW>
    <ROW><COLUMN VALUE="value11"/><COLUMN VALUE="value22"/></ROW>
    </TABLE>     
    <TABLE NAME="TABLE2">
    </TABLE>     
    The XML could then be parsed, and saved to database with JDBC by manually composing the statement strings.
    To reduce the coding effort (xml parsing, JDBC connection, etc), are there any open source projects available to achieve the above purpose? The popular O/R mapping tools like Hibernate, Castor, etc, can't handle this scanario because they require the knowledge of the tables on the server side in order to create the mapping files in advance.
    Thanks for the help!

  • Generic XML Structure solution/suggestions

    Hi,
    I am pretty new to XML, so looking for some suggestions.
    I want to create an XML structure for following data.
    I have Product P1, and Product P2
    P1 has following fields: F1,F2,F3,F4
    P2 has following fields:F0,F1, F3, F4, F5,F6
    You see both the products have some common fields and some extra fields.
    I want to make one XML structure (common to P1 and P2)that defines(tag value pair) both.
    I dont want something like say: If type == P1 then F5 and F6 field is null.
    It should not be defined for P1.
    lly F0 and F2 should not be defined for P2.
    Can anyone help me to define some common structure to accomplish this.

    Unless I'm missing something, what you want to do is set up the structure something like:
    <!element products(product*) >
    <!element product(f0*, f1*, f2*, f3*, f4* , f5*, f6*) >
    <!element f0 (#CDATA) >
    <!element f1 (#CDATA) >
    <!element f2 (#CDATA) >
    <!element f3 (#CDATA) >
    <!element f4 (#CDATA) >
    <!element f5 (#CDATA) >
    <!element f6 (#CDATA) >
    Obviously this changes depending on how often the data can recur and type of data, but this will give you an idea of DTD setup. Using schema would also give you the ability to define field length and such. Find a good DTD reference guide either online or from a book and it will give examples of the different recurring notations (*, + and the like). Hope this helps.

  • Simple XML writer

    Hi!
    I need help with appending elements in a xml-document, using java std library. What is the simpliest way to do that?
    /Jonne

    http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/Document.html
    Use createXXX and appendChild

  • "XML write" file name

    I have some weird issue with XML exporting. One day ago I have created a new metadata field and have added it to my custom made metada group. And now, then the XML file is beeing exported, to name that XML file FCServer uses the newly created metadata field value. Some time ago it was using the "Title" value to name the XML files even if I was adding new metadata fields. It is important for me to keep XML filenames exactly the same as the title value. Is it fixible or maybe I can force Final Cut Server to use the title value for naming XML files?

    Thank you for suggestion I have examined the metadata mapping, but there were no problems with it. So I have just tried to remove the metadata fields I have created and recreate them again. And it helped. So it was something wrong with the system then I was creating these metadata fields for the first time, I guess.

  • Cluster and Read Write XML

    In my applications I allow users to save their settings. I used to do this in a Ini file. So I wrote a Vi that could write any cluster and it worked ok. When I discovered that in the newer versions of LabVIEW you could Read/Write From/To xml, I changed inmediatly because it have some advantages form me but I am having some trouble.
    Every time I want to save a cluster I have to use
    Flatten To XML -> Escape XML -> Write XML
    and to load
    Load From XML -> Unescape XML -> Unflatten from XML.
    I also do other important things each time I save or load settings. So it seems to be reasonable to put all this in just two subvi's. (One for loading, One for saving). The problem is that I want to use it with any cluster
    What I want with can be summarized as following:
    - SaveSettings.vi
    --Inputs:
    ---Filename
    ---AnyCluster
    ---Error In
    --Outputs
    ---Error Out
    -LoadSettings.vi
    Inputs:
    ---Filename
    ---AnyCluster
    ---Error In
    Outputs
    ---DataFromXML
    ---Error Out
    I have tried using variants or references and I was not able to make generic sub vi (sub vi that don't know what is in the cluster). I don't want to use a polymorphic vi because it will demand making one load/save pair per each type of settings.
    Thanks,
    Hernan

    If I am correct you still you need to wire the data type to the Variant To Data. How can you put in a subvi ALL that is needed to handle the read/write of the cluster? I don't want to put any Flatten To XML or Unflatten From XML outside.
    The solution I came out with INI files was passing a reference to a cluster control but it is real unconfortable because I have to itereate through all items.
    When a control has a "Anything" input, is there any way to wire that input to a control and remains "Anything"?
    Thanks
    Hernan

Maybe you are looking for