Discussion of xml representation types

I have a discussion with a college about representations of xml data to be passed between webservice and client applications.
My Suggestion: org.w3c.dom.Document - as it appears most "modern" ways/apis or parsing xml take this as a native input and there would be no need to convert to an inputSource or other type.
Other Suggestion: A String object - supposedly because it is generic enough to be used by others.

I would still follow the standards. Serialize the XML to bytes. I don't see any point in treating so-called "internal" applications differently, it just makes it harder for people to maintain them in the future.
Besides, there's a rule that I call the "HMS Pinafore" rule of system design:
Chorus: What, never?
Singer: No, never!
Chorus: What, NEVER?
Singer: ... Hardly ever.

Similar Messages

  • Generating an XML representation of arbitrary Java objects

    Hi. Just for fun, I'm attempting to write some code which creates an XML representation of an arbitrary java object using reflection. The idea is that only properties with get/set methods should come through in the XML.
    Here is the code:
    package com.uhg.aarp.compas.persistence.common.xml;
    import java.io.IOException;
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    import java.util.ArrayList;
    import java.util.Iterator;
    import java.util.List;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.FactoryConfigurationError;
    import javax.xml.parsers.ParserConfigurationException;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.w3c.dom.Document;
    import org.w3c.dom.DOMException;
    import org.w3c.dom.Node;
    import java.util.Stack;
    public class XMLDAO {
         public static String getXMLWithHeader(Object obj){
              return "<?xml version=\"0\"?>" + getXML(obj);
          * Returns an XML representation of an arbitrary object
         public static String getXML(Object obj){
              StringBuffer buffer = new StringBuffer();
              AccessorMethod[] accessorMethods = getAccessorMethods(obj);
              buffer.append("<" + obj.getClass().getName() + ">\n");
              //List
              if(obj instanceof List){
                   List objList = (List)obj;
                   Iterator iterator = objList.iterator();
                   while(iterator.hasNext()){                              
                        buffer.append(getXML(iterator.next()));
              else{
                   for(int i = 0; i < accessorMethods.length; i++){
                        Object fieldObj = null;
                        try{
                             fieldObj = accessorMethods.invoke();
                             1. Primitive Wrapper or String(base case)
                             if(fieldObj instanceof Integer || fieldObj instanceof Float || fieldObj instanceof Double
                                  || fieldObj instanceof Long || fieldObj instanceof String){
                                  buffer.append("<" + accessorMethods[i].getAccessorFieldName() + ">");
                                  buffer.append(accessorMethods[i].invoke());
                                  buffer.append("</" + accessorMethods[i].getAccessorFieldName() + ">\n");
                             else if(fieldObj instanceof Object[]){
                                  buffer.append("<" + accessorMethods[i].getAccessorFieldName() + ">\n");
                                  Object[] fieldArray = (Object[])fieldObj;
                                  for(int j = 0; j < fieldArray.length; j++)
                                       buffer.append(getXML(fieldArray[i]));
                                  buffer.append("</" + accessorMethods[i].getAccessorFieldName() + ">\n");
                        }catch(Exception e){
                             System.out.println("Couldn't invoke method: " + accessorMethods[i].getName());
              buffer.append("</" + obj.getClass().getName() + ">\n");
              return buffer.toString();
         * Returns the Object representation for the XML - used to rebuild Java objects
         * converted to XML by XMLDAO.getXML().
         public static Object getObject(String xmlString) throws ParserConfigurationException,
              SAXException, IOException{
              //the root element is the class name
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
              DocumentBuilder builder = factory.newDocumentBuilder();
              Document document = builder.parse(xmlString);
              Stack objectStack = new Stack();
              return getObject(document);
         private static Object getObject(Node n){
              //every document is either an object or a bean property
              //all bean properties have values
              //no object has a value, it can only have bean properties
              //the base case occurs when the document has a value
              String nodeName = n.getNodeName();
              if(n.getNodeValue() == null){
                   System.out.println("node " + nodeName + " is an object");
              else{
                   System.out.println("node " + nodeName + " is a bean property");
              return null;
         * Returns all of the "getter" methods for the given object
         private static AccessorMethod[] getAccessorMethods(Object obj){
              Class theClass = obj.getClass();
              Method[] objMethods = theClass.getMethods();
              ArrayList methodList = new ArrayList();
              for(int i = 0; i < objMethods.length; i++){
                   try{
                        methodList.add(new AccessorMethod(obj, objMethods[i]));
                   }catch(IllegalArgumentException e){}
              return (AccessorMethod[])methodList.toArray(new AccessorMethod[methodList.size()]);
         * Invokes the specified "getter" method and returns the result as an Object
         private Object invokeAccessorMethod(Object obj, Method m) throws IllegalAccessException,
              InvocationTargetException{
              return m.invoke(obj, null);
    package com.uhg.aarp.compas.persistence.common.xml;
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    * Represents an AccessorMethod (i.e. getField()) on an Object
    public class AccessorMethod{
         private Object obj;
         private Method m;
         private String accessorFieldName;
         * Constructor for AccessorMethod
         public AccessorMethod(Object obj, Method m) throws IllegalArgumentException{
              1. Method name starts with get
              2. Method name does not equal get
              3. Method takes no arguments
              4. Method return type is not void
              String methodName = m.getName();
              if(methodName.indexOf("get") != 0 || methodName.length() == 3 &&
                   m.getParameterTypes().length != 0 && m.getReturnType() != null){
                   throw new IllegalArgumentException("Not a valid getter method " + methodName);
              this.obj = obj;
              this.m = m;
              String tempName = m.getName().substring(3, m.getName().length());
              this.accessorFieldName = Character.toLowerCase(tempName.charAt(0)) + tempName.substring(1, tempName.length());
         public Object invoke() throws IllegalAccessException, InvocationTargetException{
              return m.invoke(obj, null);
         * Gets the m
         * @return Returns a Method
         public Method getM() {
              return m;
         * Sets the m
         * @param m The m to set
         public void setM(Method m) {
              this.m = m;
         * Gets the accessorFieldName
         * @return Returns a String
         public String getAccessorFieldName() {
              return accessorFieldName;
         * Sets the accessorFieldName
         * @param accessorFieldName The accessorFieldName to set
         public void setAccessorFieldName(String accessorFieldName) {
              this.accessorFieldName = accessorFieldName;
         * Gets the obj
         * @return Returns a Object
         public Object getObj() {
              return obj;
         * Sets the obj
         * @param obj The obj to set
         public void setObj(Object obj) {
              this.obj = obj;
         public String getName(){
              return this.m.getName();
    I'm having some trouble figuring out how to implement the XMLDAO.getObject(Node n) method. I was thinking of maintaining a Stack of the previous Objects as I traverse the DOM, but I think that might be unnecessary work. Basically I'm wondering how I determine what the last "object" is in the DOM from any given node. Anyone have any input?

    I think the end of my post got cut off:
    I'm having some trouble figuring out how to implement the XMLDAO.getObject(Node n) method. I was thinking of maintaining a Stack of the previous Objects as I traverse the DOM, but I think that might be unnecessary work. Basically I'm wondering how I determine what the last "object" is in the DOM from any given node. Anyone have any input?

  • XML Data Type in oracle

    I am a developer in .NET with having experience working on SQL server.
    I want to know whether there is an xml data type in oracle.
    I have an xml in my front end and want to insert record in the database for the values inside that xml. What i am doing currently is that i am retreiving the value in the xml in the .NET code and passing the values a parameter to a stored procedure in oracle. what i want to do is to pass the xml directly to stored procedure in oracle and retrieve the values there (using Xquery) and insert the records.
    This is possible with SQL server 2005. I want to know is this possible with Oracle.
    Thanks and regards,
    Sameer J Narkar

    Wonderful - a documentation question!
    You will find your answer by going to the general documentation portal at http://tahiti.oracle.com following the path to the database version of interest, and looking in the SQL Reference manual. Chapter 2 discusses all data types, including the several supported for XML.
    In addition, under the 'Books' tab, there are several XML-developer specific reference manuals.
    (Oracle's support for XML generally blows away the others. The price for the extreme flexibility is an ease-of-use hit.)
    Message was edited by:
    Hans Forbrich
    removed the punctuation from the displayed URL which resulted in an automatically included trailing comma.

  • DSC with XML data type

    Hi,
    Can someone explain to me what the difference is between the xml data type and the Document data type in workbench? I would like to use the xml datatype in my DSC thinking it is most likely the best representation of an xml string. But I've heard that Document is more widely used and that it can represent an xml entity as well. Is this right?
    My ultimate goal is to write a DSC and use a type that represent an xml string. I would like the component.xml to have the type for my input variables to automatically be typed as "xml" or "document" (whatever the one i should be using is).
    I tried creating variables of both types ("xml' and "document", lower case d) and have those passed into my DSC for inspection. The object passed in are as follows:
    xml: org.apache.xerces.dom.DocumentImpl
    document: com.adobe.idp.Document
    But if I use any of those in my component.xml, workbench is typing my variables as "DocumentImpl" or "Document".
    Any ideas?
    Thanks in advance!
    Nic

    The xml variable (org.w3c.doc.Document) is a native xml data type. That means you can use xml functions and/or xPath expressions on the content of the variable.
    The document variable (com.adobe.idp.Document) is a more generic data type that can store any binary data. If you happen to store xml in that data type, you won't be able to run xml functions or xPath expression directly on the variable content since it's treated as binary data.
    If  you don't need to manipulate or access the content of the xml, then either data types will work. Otherwise, I would use the xml data type.
    In your component xml, make sure your xml data type is set to org.w3c.doc.Document and you'll see xml in Workbench.
    Jasmin

  • Named file entity do not load in from xml files(eg., !DOCTYPE PURANA SYSTEM "purana.dtd" [ !ENTITY CHAPTER_1 SYSTEM "./chapter_1.xml" ] ?xml-stylesheet type="text/xsl" href="purana.xsl"? PURANA TITLE /TITLE &CHAPTER_1; /PURANA )

    I create several file name entities in an external DTD.
    It used to work sometimes back but I don't remember now when it begun to fail.
    typical document for eg., is given below:
    <!DOCTYPE PURANA SYSTEM "purana.dtd" [ <!ENTITY CHAPTER_1 SYSTEM "./chapter_1.xml"> ]>
    <?xml-stylesheet type="text/xsl" href="purana.xsl"?> <PURANA>
    <TITLE>
    </TITLE>
    &CHAPTER_1;
    </PURANA>)
    the abbreviation used to work by loading the file using XSL script,
    but now it does not even work when the entity is defined within the XML document itself.

    Too difficult???
    Please helped me.
    Thank you, Theo

  • Japanese characters alone are not passing correctly (passing like ??? or some unreadable characters) to Adobe application when we create input variable as XML data type. The same solution works fine if we change input variable data type to document type a

    Dear Team,
    Japanese characters alone are not passing correctly (passing like ??? or some unreadable characters) to Adobe application when we create input variable as XML data type. The same solution works fine if we change input variable data type to document type. Could you please do needful. Thank you

    Hello,
    most recent patches for IGS and kernel installed. Now it works.

  • (261705413) Q RPCC-21 Missing text/xml MIME-type for WSDL files?

    Q<RPCC-21> Would it mess up the SOAP operations that clients do when using the
    WSDL in a dynamic client to put a text/xml mime type in the WSDL-providing jsp?
    A<RPCC-21>: It is a known issue that the MIME-type for WSDL files is not appropriately
    transmitted so some web browsers will not identify an appropriate helper application
    when they are viewed (for Netscape just press Ctrl-U to view the source). This,
    however, does not affect the dynamic client as evidenced by the example code seen
    in the code demonstration.
    Adam

    SR,
    You probably already have the answer by now, but I just came across the same problem and found the answer elsewhere.
    The trick is to have the JavaMail jar in your classpath BEFORE the JAF jar. Given the habit of my development environment to sort jars alphabetifally it had me stumped for a bit.
    Good luck
    Marc

  • Identifying an XML document type

    I am reading XML message off a queue using JMS and I want to determine the XML document type so I can use the proper schema for validation. Since different XML documents will be coming in off the same queue I need to determine the document type so I can use the proper schema for validation.
    Is there a good way to do this? So far I have been doing the following but I am looking for a better solution:
    *Use the JMS headers to store the XML message type.  Not always possible.
    *Read the first few lines of the XML as a file and parse for the root node or .xsd.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    What I am refering to is a situation where I have one queue that has multiple incoming XML documents.
    For example:
    PurchaseOrder.xml needs to be read off a queue validated via PurchaseOrder.xsd
    PartsOrder.xml needs to be read off the same queue and validated with PartsOrder.xsd. I am trying to find and eloquent solution to identify if I have a PartsOrder or a PurchaseOrder, so I can set the proper schema for validation when parsing the XML doc.

  • Xml data type is not supported in distributed queries. Remote object 'OPENROWSET' has xml column(s).

    Hi,
    Can anyone help me out please.
    I have written one stored Procedure to create a views using Openrowset(openquery) but for tables which contains xml data types throwing error while executing the SP. Error
    " Xml data type is not supported in distributed queries. Remote object 'OPENROWSET' has xml column(s)."
    Please refer the Stored Procedure & error message below.
    USE [Ice]
    GO
    /****** Object:  StoredProcedure [dbo].[Pr_DBAccess]    Script Date: 08/14/2014 16:08:20 ******/
    SET
    ANSI_NULLS ON
    GO
    SET
    QUOTED_IDENTIFIER ON
    GO
    ALTER
    PROCEDURE [dbo].[ Pr_DBAccess](@SERVERTYPE
    NVARCHAR(50),@SERVERNAME
    NVARCHAR(100),@DATABASENAME
    NVARCHAR(100),@SCHEMANAME
    NVARCHAR(100),@TABLENAME
    NVARCHAR(100),@USERNAME
    NVARCHAR(100),@PASSWORD
    NVARCHAR(100))
    AS
    BEGIN
    DECLARE @openquery
    NVARCHAR(4000),
    @ETL_CONFIG_IDN
    NVARCHAR(100);
     IF @SERVERTYPE='SQL'
     BEGIN
    SET @openquery= 
    'CREATE VIEW '+@TABLENAME+
    ' WITH ENCRYPTION AS SELECT * FROM OPENROWSET(''SQLNCLI'',''SERVER='+@SERVERNAME+';TRUSTED_CONNECTION=YES;'',''SELECT * FROM '+@DATABASENAME+'.'+@SCHEMANAME+'.'+@TABLENAME+''')'
    SELECT @openquery
    END
    EXECUTE
    sp_executesql @openquery
    END
    ----While running the SP manually below error occured

    HI ,
    1. You cannot use a table or view that contains xml or clr type as 4-part name in your query
    2. You need to cast the column to either nvarchar(max) or varbinary(max) or other appropriate type to use
    3. If you have a table that has xml type for example then you need to create a view that contains all columns other than xml and query it instead. Or you can issue a pass-through query using OPEN QUERY with the appropriate columns only.
    Here is a work around:
    SELECT
          Cast(a.XML_Data as XML) as XML_Data
    FROM
          OPENQUERY([LINKED SERVER NAME HERE],'
              SELECT
                Cast(XML_Data as Varchar) as XML_Data
             FROM
                [DATABASE NAME].[SCHEMA].[TABLE NAME]'
    ) a
    Basically, the data is queried on the remote server, converts the XML data to a varchar, sends the data to the requesting server and then reconverts it back to XML.
    You can take help from below link;
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/c6e0f4da-821f-4ba2-9b01-c141744076ef/xml-data-type-not-supported-in-distributed-queries?forum=transactsql
    Thanks

  • Xml representation of a string

    hi all,
    how do i make an xml representation of a string..if anyone knows please post it.
    thanks

    wow, you guys must be all in the same class, that's 3 times this question has been asked. Look below...

  • XML dateTime type with timezone info.

    Has anyone have problem FTPing xml that conforms to a xml schema with dateTime type?
    This is the format of standard XML dateTime type:
    "2003-12-17T09:30:47-05:00"
    I used the Oracle timestamp datatype, but oracle rejected the dateTime of XML with the error message
    "ORA-01830: date format picture ends before converting entire input string."
    I have altered the database to use timezone information:
    // For eastern time zone.
    alter DATABASE SET time_zone = 'Etc/GMT-5';
    and use the native oracle datatype
    "TIMESTAMP WITH TIME ZONE"
    but still doesn't work. I also changed the XML time data to "2003-12-17 09:30:47-05:00", still no good.

    I tried couple formats, they all seem to need the "T" in between date and time. If I don't have the "T", I get the error message "ORA-01861: literal does not match format string"
    If I use the following input I get the error message
    "ORA-31041: Property CreateDate: Memory type (180) not compatible with database type (121)"
    "2003-12-11T21:30:47.0"
    "2003-12-11T21:30:47.000000"
    "2003-12-11T21:30:47.000000000"
    "2003-12-11T21:30:47000000"
    "2003-12-11T21:30:470000"
    If I use the following I get error message "ORA-01830: date format picture ends before converting entire input string"
    "2003-12-11T21:30:470000-04:00"
    "2003-12-11T21:30:47.000000-05:00"
    "2003-12-11T21:30:47.0-05:00"
    It leads me to think that "2003-12-11T21:30:47.000000"
    is the picture(mask) used by the database. But it has extra "T" in it, and oracle doesn't understand the datatype. Maybe there are two validation going on? one from schema and another during insertion to database? Schema requires "T", but database doesn't understand "T"?
    Am I in the right track?
    Do you know how do I query the mask used?
    Thanks,
    --Benjamin                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Source XML data type declaration querry

    Hi all,
    I am very confused in below XML data type declaration.
    I am dealing first time with this type of XML.
    In source XML header items are mentioned in header node(address).
    <address addressline1="6th & Hunt" addressline2="" city="Pryor" state="OK" country="Sun" zip="74361">
    - <phoneinfo>
      <phone type="work">9999999999</phone>
      </phoneinfo>
    - <faxinfo>
      <fax>100000001</fax>
      </faxinfo>
    </address>
    Please Help in the "Data type declaration" of above source XML????
    How can i use this data type in message mapping????
    Thanks & Regards

    Hi Umesh,
    You can use Data types with Attributes in XI.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/3b/d2a3f7a166514abb8cf5635b71974f/frameset.htm
    And you can even try with the External Definition also.
    Hope this helps,
    regards,
    Moorthy

  • [JAXB 2.x] Defining the XML Schema Type for XmlElementDecl

    How can an XML Schema Type (XmlSchemaType) be defined for an XmlElementDecl/Ref?
    The classes are as follows:
        @XmlRegistry
        class ObjectFactory {
            // XmlSchemaType is desired, but cannot be used with XmlElementDecl/Ref: @XmlSchemaType(name = "unsignedShort")
            @XmlElementDecl(namespace = "urn:com:test:namespace", name = "char", scope = com.test.Arguments.class)
            @XmlJavaTypeAdapter(com.test.CharacterAdapter.class )
            public JAXBElement<Character> createArgumentsChar(Character value) {
                return new JAXBElement<Character>(_ArgumentsChar_QNAME, Character.class, com.test.Arguments.class, value);
        @XmlAccessorType(XmlAccessType.FIELD)
        @XmlType(name = "", propOrder = { "arguments" })
        class Arguments {
            @XmlElementRefs( {
                    @XmlElementRef(name = "char", namespace = "urn:com:test:namespace", type = JAXBElement.class),
            protected List<JAXBElement<?>> arguments;
        }The desired schema is as follows:
        <xs:element name="arguments" minOccurs="0">
            <xs:complexType>
                <xs:sequence>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:element name="char" type="xs:unsignedShort" />
                    </xs:choice>
                </xs:sequence>
            </xs:complexType>
        </xs:element>However, when generating the schema from these classes (schemagen), the resulting "char" element type is "xs:string," not "xs:unsignedShort" as desired. What annotation can be used to indicate that the type should be xs:unsignedShort? If the addition of an annotation is not possible, are there any other ways to accomplish this?
    Message was edited by: Shelley (Indicated "JAXB 2")

    There are mappings between XSD type and Java type table on the Sun website.

  • Oracle BI Administration Tool 11g - Fields have the XML data type

    I'm using Oracle BI Administration Tool 11.1.1.3.0 and I need to import Metadata an Oracle table where same fields have the XML data type.
    Please, there is someone can tell me what I must do to define these fields in Administration Tool?
    Regards.

    Hi,
    in u r RPD -->Try to select import Connection Type as : XMLA then give it the URL of u r analysis services 2000 then u can able to import it.
    refer:
    http://www.biblogs.com/2008/02/01/obiee-hybrid-olap-reporting-using-ms-analysis-services-oracle/
    http://www.rittmanmead.com/2007/11/essbase-integration-with-obiee-101331/
    Thanks
    Deva

  • XML Data Type

    Hi
    Does the latest version of Designer support XML Data Type?
    Thanks,
    Ila

    No there is no direct support for XML datatype..
    However, you can follow Note 204966.1 Using Designer Domains to Exploit New Datatypes
    hope this helps

Maybe you are looking for

  • Missed command field on easy access screen

    hai guys, i am just the starter of SAP. while browsing the screen , i dont know what i did and finally i lost my command field in easy access screen. please let me know how to 2 get it back.i think u understood what i mean.the field where we give com

  • How do i delete facetime forever???

    how do I delete FACETIME forever???

  • My New Macbook Air :(

    I have just converted from window pc to mac. I got my new macbook air on 21 October 2011, the first day I charging my macbook air I could feel the a light electrical current in my hand, it's serious and horrible. thus, I have contacted apple shop, an

  • Consideration of DBFS when doing a switchover/failover to standby

    Can anyone let me know if i can configure the DBFS separated from the Production database with a dataguard standby to reduce the impact on my production database?

  • Will not shutdown

    I know how to use the on/off button, but why is it locking up in the first place, everytime I try to shutdown?