WBEM SDK - Mapping CIM Object to XML

Hi all !
In Sun WBEM SDK such classes as CIMClass, CIMProperty, CIMInstance have
methods toXML(.....).
Where can I find specification, used for CIM-to-XML mapping in Sun WBEM SDK?
I will appreciate any assistance you might be able to offer me.
Thank you in advance for your attention.
Please, mail me on [email protected]
Sincerely yours,
Ihor Krivenchuck

To construct an object from XML, builder pattern looks like a good option. Here is a quick design
public class XMLCoder{
public static Object decode(InputSream in, XMLBeanMapper xm) throws some_exception_if_ASM_object_is_in_inconsistent_state {
public static void encode(OutputStream out, XMLBeanMapper){
public class BeanProperty{
private String name;
priavte String value;
.. cons,accessors and muatators ...
public interface XMLBeanMapper{
public void setProperty(BeanProperty bp);
public Object getObject() throws some_exception_if_ASM_object_is_in_inconsistent_state ;
public BeanProperty getNextProperty();//returns null if no more property needs to be converted to xml
for each class that needs conversion to and from XML, you need a XMLBeanMapper class.
XMLCoder.encode parses XML, creates a BeanProperty from each element and calls setProperty of XMLBeanMapper. The XMLBeanMapper calls necessary method of your ASM object to set the value. When it is done with parsing the xml document, it calls the getObject on the XMLBeanMapper and returns the object or throws exception if needed.
XMLCoder.decode keeps calling the getNextProperty unless it returns null. It writes necessary xml element from the data provided by the BeanProperty instance.
Depending on how complex your xml is you will probably need to change the BeanProperty class to keep the XMLcoder generic. For example to handle child elements, you may chain BeanProperty instances, or if the XML may have arbitrarily more information for a property than a name-value pair, you may need to use a hashtable.
Benefits:
You have a generic class to parse XML
The unique XmlBeanMapper implementation for each ASM type will be pretty simple. You can have a generic XmlBeanMapper implementation when the xml elements contains the name of the method
Disadvantages:
You need to write and maintain a XMLBeanMapper implementation for each type of ASM class.

Similar Messages

  • How to combine "Object-to-XML (OXM)" and "Direct to XML Type" mapping?

    hi
    If I have an XMLType column in my table (wich I can map using TopLink) and I have defined the structure of the contents of this XMLType column using XML Schema (wich I can map using Toplink), how can I combine both types of TopLink mappings "as transparently as possible"?
    for "Object-to-XML (OXM)" mapping
    see http://www.oracle.com/technology/products/ias/toplink/technical/tips/ox/index.htm
    for "Direct to XML Type" mapping
    see http://www.oracle.com/technology/products/ias/toplink/doc/1013/main/_html/relmapun004.htm#CHDFIFEF
    thanks
    Jan Vervecken

    Thanks for your reply James Sutherland.
    Although I haven't used a "TopLink Converter" before, this seems like a good idea.
    The thing is that the "TopLink Workbench Editor" for my "Direct to XML Type" mapping doesn't have a "Converter" tab, some other mapping type editors do have such a "Converter" tab.
    I'm not sure if I completely understand how such a "TopLink Converter" is supposed to work. How many attributes do I need in the "XMLRow" Java object for the "MY_XML" column in the "XML_TABLE" table I try to map to?
    I suppose I should try to get a situation where the "XMLRow" Java object has an "myXML" attribute of Java class type "MyXML" (where "MyXML" has been mapped to an XML Schema), not?
    So do I also still need an attribute "myXMLDocument" of type org.w3c.dom.Document as I do now for the "Direct to XML Type" mapping?
    Oh, by the way ... for anyone who hits this forum thread looking for the reason why the TopLink Workbench reports the problem "Attribute must be assignable to java.lang.String, org.w3c.dom.Document, or org.w3c.Node" while your attribute is of such a type, read this forum post
    Re: Toplink WB 10.1.3 - Aggregate field mapping bug and XMLType question
    For me the "Direct to XML Type" mapping works fine, just ignoring the waring. This is supposed to be bug number 5071250.
    thanks
    Jan Vervecken

  • Invoke-WSManAction command and CIM Object references

    Hi,
    I am using powershell on my Windows Server 2008 R2 system to invoke a CIM class method that takes a reference object argument. The signature of the method is something like:
    uint32 DoSomething([IN, Description(" Does something ")] CIM_LogicalPort ref Target);
    The command I use to invoke this method is:
    PS C:\Users\Administrator> $list = Get-WSManInstance -Enumerate -ResourceURI "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/****/CIM_FCPort" -ReturnType EPR
    PS C:\Users\Administrator>
    PS C:\Users\Administrator> invoke-wsmanaction -action DoSomething -resourceuri "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/****/CIM_SoftwareInstallationService" -selectorset @{CreationClassName="CIM_SoftwareInstallationService";Name="CIM_SoftwareInstallationService";SystemCreationClassName="CIM_ComputerSystem";SystemName="testServer"}
    -ValueSet @{Target=$($list[0].InnerXml)}
    xsi         : http://www.w3.org/2001/XMLSchema-instance
    p           : http://schemas.microsoft.com/wbem/wsman/1/wmi/root/****/CIM_SoftwareInstallationService
    cim         : http://schemas.dmtf.org/wbem/wscim/1/common
    lang        : en-US
    ReturnValue : 32968
    PS C:\Users\Administrator>
    Though the command execution succeeds, the CIM Provider fails as the reference argument passed in the powershell command reaches the provider as NULL.
    My questions are:
      1. What is the right way to pass the CIM objects by reference to the methods?
      2. Is the syntax of the commands I am using correct?
    Notes:
      - I have tried the same thing with "winrm" and "Invoke-CIMMethod" commands as well, but with the same failure.
      - The same commands seem to have worked for some people in a similar scenario (http://somethingaboutcode.wordpress.com/2009/11/09/invoking-hyper-v-wmi-api-methods-with-reference-parameters-using-ws-management/).
    I really appreciate any help on this.
    Cheers,
    Venu

    Hello AnnaWY,
    First of all, thanks for the reply.
    In fact, that is the link I followed to get my commands and it was very helpful. I think the EPR is reaching the WINRM server as it is supposed to (I have verified it with wireshark capture when executing the command remotely; copy-pasted below), but when
    it reaches the CIM Provider, it is NULL. I suspect one of the below might be happening:
      1. WINRM is not able to get the object from the EPR.
      2. WINRM is passing the argument as NULL when invoking the method.
      3. Something could be going wrong during marshalling (?!!).
    Is there a way to know which one of the above is the case?
    Please note: I have tried enabling the "WMI" and "Windows Remote Management" traces and it didn't help much.
    Thanks again,
    Venu
    REQUEST
    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd" xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">
        <s:Header>
            <a:To>http://10.192.203.53:5985/wsman</a:To>
            <w:ResourceURI s:mustUnderstand="true">http://schemas.microsoft.com/wbem/wsman/1/wmi/root/****/CIM_SoftwareInstallationService</w:ResourceURI>
            <a:ReplyTo>
                <a:Address s:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
            </a:ReplyTo>
            <a:Action s:mustUnderstand="true">http://schemas.microsoft.com/wbem/wsman/1/wmi/root/****/CIM_SoftwareInstallationService/DoSomething</a:Action>
            <w:MaxEnvelopeSize s:mustUnderstand="true">153600</w:MaxEnvelopeSize>
            <a:MessageID>uuid:2A713DC6-F79A-452F-9AA6-D19D9A929C9B</a:MessageID>
            <w:Locale s:mustUnderstand="false" xml:lang="en-US"/>
            <w:OperationTimeout>PT60.000S</w:OperationTimeout>
            <w:SelectorSet>
                <w:Selector Name="CreationClassName">CIM_SoftwareInstallationService</w:Selector>
                <w:Selector Name="Name">CIM_SoftwareInstallationService</w:Selector>
                <w:Selector Name="SystemCreationClassName">CIM_ComputerSystem</w:Selector>
                <w:Selector Name="SystemName">testServer</w:Selector>
            </w:SelectorSet>
        </s:Header>
        <s:Body>
            <p:DoSomething_INPUT xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/wmi/root/****/CIM_SoftwareInstallationService">
                <p:Target>
                    <a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
                    <a:ReferenceParameters>
                        <w:ResourceURI>http://schemas.microsoft.com/wbem/wsman/1/wmi/root/****/CIM_FCPort</w:ResourceURI>
                        <w:SelectorSet>
                            <w:Selector Name="CreationClassName">CIM_FCPort</w:Selector>
                            <w:Selector Name="DeviceID">0000ABCDABCD0000</w:Selector>
                            <w:Selector Name="SystemCreationClassName">CIM_ComputerSystem</w:Selector>
                            <w:Selector Name="SystemName">testServer</w:Selector>
                        </w:SelectorSet>
                    </a:ReferenceParameters>
                </p:Target>
            </p:DoSomething_INPUT>
        </s:Body>
    </s:Envelope>
    RESPONSE
    <s:Envelope xml:lang="en-US" xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:x="http://schemas.xmlsoap.org/ws/2004/09/transfer" xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"
    xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/wsman.xsd">
        <s:Header>
            <a:Action>http://schemas.microsoft.com/wbem/wsman/1/wmi/root/****/CIM_SoftwareInstallationService/DoSomethingResponse</a:Action>
            <a:MessageID>uuid:25561441-A48B-4DDF-B201-BDD00024EC25</a:MessageID>
            <a:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:To>
            <a:RelatesTo>uuid:2A713DC6-F79A-452F-9AA6-D19D9A929C9B</a:RelatesTo>
        </s:Header>
        <s:Body>
            <p:DoSomething_OUTPUT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/wmi/root/****/CIM_SoftwareInstallationService" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common">
                <p:ReturnValue>32968</p:ReturnValue>
            </p:DoSomething_OUTPUT>
        </s:Body>
    </s:Envelope>

  • Blaze DS - Mapping java object into another java application

    Good afternoon,
    I realized a Client-Server application. Server is Java-based. Client is Flex. Server services are accessible through Blaze DS.
    Now I have some Java clients that need to access server services. Blaze DS permits to do it simply but I don't know how to map java objects as I do using [RemoteClass(alias.....)] construct at Actionscript side.
    For example, server sends a MyObjectType and client receives an ASObject.
    Is there a way to map java MyObjectType automatically at destination?
    Thank you for help and sorry for poor english.
    Regards, Francesco

    xstream will convert any given java object to xml. Not sure what support it offers for schemas.
    http://xstream.codehaus.org/

  • Object to xml inheritance feature in toplink

    i created a project for object to xml mapping but require "inheritance features to be included ".i tried but it gives --"missing class indicator " and other root error
    any help please

    or send me your email i will mail you the require stuff as its to much to paste here my id is ::[email protected]
    or [email protected]

  • Exception [type: SIGSEGV, Address not mapped to object]

    Hi,
    I'm working on an Oracle Database 11g Release 11.1.0.6.0 - 64bit Production With the Real Application Clusters option.
    I'm trying to execute the below:
          SELECT /*+ CURSOR_SHARING_EXACT */
                 vc.id_vehicle, gr.geoRouteId, g.name, round(g.length) length_, gr.active,
                 g.id_user id_user_georoute_owner, gr.grBindUserId id_user_bind_owner,
                 (SELECT count(*) FROM dual WHERE XMLEXISTS('$XML_ALM/user/alarmwhen[@direction="out"]' passing gr.geoRouteUser AS "XML_ALM") = 1) alm_out
            FROM configurator.t_vehicle_configuration vc, dispatch.v_georoute g,
                 xmltable('$XML/vehicleconf/GeoRoute/geoRoute[@active="1"]'
                   passing vc.x_configuration AS "XML"
                   columns geoRouteId   number  path '@id',
                           active       number  path '@active',
                           grBindUserId number  path '@id_user',
                           geoRouteUser xmltype path 'user'
                 ) gr
           WHERE vc.id_vehicle = 453
             AND g.id_georoute = gr.geoRouteId;but after few seconds I got the error in the object.
    The alert log says:
    +Exception [type: SIGSEGV, Address not mapped to object] [ADDR:0x38] [PC:0x483CEFD, evahtr()+495]+
    Errors in file /u01/app/oracle/diag/rdbms/evodb/EVODB2/trace/EVODB2_ora_13769.trc  (incident=301686):
    +ORA-07445: exception encountered: core dump [evahtr()+495] [SIGSEGV] [ADDR:0x38] [PC:0x483CEFD] [Address not mapped to object] []+
    Incident details in: /u01/app/oracle/diag/rdbms/evodb/EVODB2/incident/incdir_301686/EVODB2_ora_13769_i301686.trc
    The trace doesn't say more:
    +ORA-07445: exception encountered: core dump [evahtr()+495] [SIGSEGV] [ADDR:0x38] [PC:0x483CEFD] [Address not mapped to object] []+
    +========= Dump for incident 301686 (ORA 7445 [evahtr()+495]) ========+
    ----- Beginning of Customized Incident Dump(s) -----
    +Exception [type: SIGSEGV, Address not mapped to object] [ADDR:0x38] [PC:0x483CEFD, evahtr()+495]+
    The strange stuff is that if I remove the
    (SELECT count(*) FROM dual WHERE XMLEXISTS('$XML_ALM/user/alarmwhen[@direction="out"]' passing gr.geoRouteUser AS "XML_ALM") = 1) alm_out
    from the query, there is no problem.
    Do you have any suggestion?
    Thanks in advance,
    Samuel

    The strange stuff is that if I remove the
    (SELECT count(*) FROM dual WHERE XMLEXISTS('$XML_ALM/user/alarmwhen[@direction="out"]' passing gr.geoRouteUser AS "XML_ALM") = 1) alm_out
    from the query, there is no problem.That's probably because you're not using XMLExists correctly.
    The function returns a boolean value so you don't need to test for 1 or 0 as we had to with existsNode function before :
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28369/xdb04cre.htm#sthref360
    It's also probably better to use a CASE expression instead of a subquery :
    SELECT /*+ CURSOR_SHARING_EXACT */
           vc.id_vehicle
         , gr.geoRouteId
         , g.name
         , round(g.length) length_
         , gr.active
         , g.id_user id_user_georoute_owner
         , gr.grBindUserId id_user_bind_owner
         , case when XMLExists('$XML_ALM/user/alarmwhen[@direction="out"]' passing gr.geoRouteUser AS "XML_ALM")
                then 1
                else 0
           end as alm_out
    FROM configurator.t_vehicle_configuration vc
       , dispatch.v_georoute g
       , xmltable('$XML/vehicleconf/GeoRoute/geoRoute[@active="1"]'
                   passing vc.x_configuration AS "XML"
                   columns geoRouteId   number  path '@id',
                           active       number  path '@active',
                           grBindUserId number  path '@id_user',
                           geoRouteUser xmltype path 'user'
         ) gr
    WHERE vc.id_vehicle = 453
    AND g.id_georoute = gr.geoRouteId
    ;Even better, you can test the condition directly in the COLUMNS clause with fn:exists XPath function.
    For example, something like this :
    SQL> with sample_data as (
      2    select xmltype('<root>
      3  <row><item>1</item><other id="a"/><other id="x"/></row>
      4  <row><item>2</item><other id="b"/></row>
      5  <row><item>3</item><other id="b"/></row>
      6  </root>') doc
      7    from dual
      8  )
      9  select x.*
    10  from sample_data t
    11     , xmltable(
    12         '/root/row'
    13         passing t.doc
    14         columns item number path 'item',
    15                 flag number path 'exists(other[@id="x"])'
    16       ) x
    17  ;
          ITEM       FLAG
             1          1
             2          0
             3          0

  • How do I add a variable into an object as xml

    I have a xml document with 2 protection order numbers. I want to get the information for one of them which is **protectionOrderNumber="1400042"**. I would like to add strPoNumber variable to the object objXmlCaseDoc. Inside this object is the xml
    that was read and put inside the object. I want at the beginning of the xml code inside the objXmlCaseDoc to add the protectionOrderNumber at the end of the first line. This should be added at the beginning of the xml document. In my object (objXmlCaseDoc)
    there is no variable strPoNumber. This is why I want to add it at the top. The object has xml document in it. 
    It should look like this:
    <Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com" xmlns:CMCodeQueryHelper="urn:CMCodeQueryHelper" protectionOrderNumber="1400042">
    My vb code: I have the variable strPoNumber and the object where the xml document is. Object name is objXmlCaseDoc
    I want to add the line of code where I have comment Tranform case information into the output format near the bottom of the code.
    Option Strict On
    Option Explicit On
    Imports System.Xml
    Public Class BcaPoRequests
    Shared Sub Main()
    Dim objMessageProcessor As New MessageProcessor
    Dim objSchemasCollection As New Msc.Integration.MessageBroker.Library.v4.SchemasCollection
    Dim objTransformsCollection As New Msc.Integration.MessageBroker.Library.v4.TransformsCollection
    objMessageProcessor.ProcessInputQueue(False, False, objSchemasCollection, objTransformsCollection)
    End Sub
    Private Class MessageProcessor
    Inherits Msc.Integration.ServiceCatalog.Library.v4.SoapMessageProcessor
    Protected Overrides Sub ProcessMessage(ByRef aobjBroker As ServiceCatalog.Library.v4.Broker, ByRef aobjXMLInputSoapEnvelopeDoc As System.Xml.XmlDocument, ByRef aobjInstantiatedObjectsCstrollection As Microsoft.VisualBasic.Collection, ByRef aobjConsumer As ServiceCatalog.Library.v4.Consumer)
    MyBase.ProcessMessage(aobjBroker, aobjXMLInputSoapEnvelopeDoc, aobjInstantiatedObjectsCollection, aobjConsumer)
    Dim objXmlMessageDoc As XmlDocument
    Dim objXmlMessageNode As XmlNode
    Dim objNameTable As NameTable
    Dim objXMLNameSpaceManager As XmlNamespaceManager
    Dim objXMLSchemaException As Xml.Schema.XmlSchemaException
    Dim strCaseNumber As String
    Dim strPoNumber As String
    Dim objXmlCaseDoc As XmlDocument
    'create a namespace manager used for queries into inputmessage (because of namespace)
    objNameTable = New NameTable
    objXMLNameSpaceManager = New XmlNamespaceManager(objNameTable)
    objXMLNameSpaceManager.AddNamespace("ext", "http://www.courts.state.mn.us/ProtectionOrderExtension/1.0")
    objXMLNameSpaceManager.AddNamespace("exc", "http://www.courts.state.mn.us/ProtectionOrderQuery/1.0")
    objXMLNameSpaceManager.AddNamespace("soap", "http://www.w3.org/2003/05/soap-envelope")
    objXMLNameSpaceManager.AddNamespace("wsa", "http://schemas.xmlsoap.org/ws/2004/08/addressing")
    objXmlMessageNode = aobjXMLInputSoapEnvelopeDoc.DocumentElement.SelectSingleNode("soap:Body/exc:ProtectionOrderQueryRequest", objXMLNameSpaceManager)
    objXmlMessageDoc = New XmlDocument
    objXmlMessageDoc.LoadXml(objXmlMessageNode.OuterXml)
    'Check authorization
    'Validate the input message
    objXMLSchemaException = aobjBroker.ValidateXmlDocument(objXmlMessageDoc, "ProtectionOrderQuery_1_0.xsd", "NiemExchanges\ProtectionOrders\Exchange", , False)
    If Not objXMLSchemaException Is Nothing Then
    'return fault if invalid
    aobjBroker.Reply(aobjBroker.CreateSoapFault(Msc.Integration.Utility.Library.v4.Soap.udtSoapCodes.Sender, Msc.Integration.Utility.Library.v4.Xml.FormatXmlSchemaValidationErrorText(objXMLSchemaException), Msc.Integration.Utility.Library.v4.Soap.udtSoapRoles.RoleUltimateReceiver, aobjXMLInputSoapEnvelopeDoc, "soap:InvalidMessage", "soap:Body", Msc.Integration.Utility.Library.v4.Soap.GetReplyEndpointReference(aobjXMLInputSoapEnvelopeDoc), aobjXMLInputSoapEnvelopeDoc.DocumentElement.SelectSingleNode("soap:Header/wsa:MessageID", objXMLNameSpaceManager).InnerText, aobjConsumer))
    Exit Sub
    End If
    'Get the case number and the PO number from the input message
    strCaseNumber = objXmlMessageDoc.DocumentElement.SelectSingleNode("ext:CourtFileNumber", objXMLNameSpaceManager).InnerText
    strPoNumber = objXmlMessageDoc.DocumentElement.SelectSingleNode("ext:ProtectionOrderID", objXMLNameSpaceManager).InnerText
    'Get the case information from Mncis
    'Code for calling the case
    objXmlCaseDoc = Msc.Integration.Mncis.Library.v4.Case.GetIxmlForCaseNumber(strCaseNumber, "CourtCaseHeader,ProtectionOrder,SubjectParties,HearingTrialSetting", False)
    'Tranform case information into the output format
    End Sub
    End Class
    End Class
    xslt code
    <?xml version="1.0" encoding="UTF-8"?>
    <?altova_samplexml file:///Z:/Training%20with%20Tim%20XML%20code%20various/BcaRequestIxml.xml?>
    <xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:poq="http://www.courts.state.mn.us/ProtectionOrderQuery/1.0" xmlns:ext="http://www.courts.state.mn.us/ProtectionOrderExtension/1.0" xmlns:nc="http://niem.gov/niem/niem-core/2.0" xmlns:j="http://niem.gov/niem/domains/jxdm/4.1" xmlns:mscef="courts.state.mn.us/extfun" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:exsl="urn:schemas-microsoft-com:xslt" extension-element-prefixes="exsl" exclude-result-prefixes="mscef msxsl exsl">
    <xsl:import href="../General/ExtensionFunctions.xsl"/>
    <xsl:import href="MNCIS_PO_BCA_ProtectionOrder_1_0.xsl"/>
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <!-- Path to environment folder used by document function. Relative to location of stylesheet. -->
    <xsl:param name="gEnvPath">../..</xsl:param>
    <xsl:template match="/">
    <xsl:variable name="vPoNumber">
    <xsl:value-of select="Integration/@protectionOrderNumber"/>
    </xsl:variable>
    <poq:ProtectionOrderQueryResponse>
    <xsl:for-each select="//Integration/ProtectionOrder[ProtectionOrderNumber=$vPoNumber]">
    <xsl:call-template name="ProtectionOrder"/>
    </xsl:for-each>
    </poq:ProtectionOrderQueryResponse>
    </xsl:template>
    </xsl:stylesheet>
    XML document output  from my xslt code
    <?xml version="1.0" encoding="UTF-8"?>
    <poq:ProtectionOrderQueryResponse xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:poq="http://www.courts.state.mn.us/ProtectionOrderQuery/1.0" xmlns:ext="http://www.courts.state.mn.us/ProtectionOrderExtension/1.0" xmlns:nc="http://niem.gov/niem/niem-core/2.0" xmlns:j="http://niem.gov/niem/domains/jxdm/4.1">
    <ext:ProtectionOrder xmlns:exc="http://www.courts.state.mn.us/ProtectionOrderServiceExchange/1.0" xmlns:s="http://niem.gov/niem/structures/2.0" xmlns:usps="http://niem.gov/niem/usps_states/2.0">
    <j:CourtOrderEnforcementAgency>
    <nc:OrganizationIdentification>
    <nc:IdentificationID>MN0700000</nc:IdentificationID>
    </nc:OrganizationIdentification>
    </j:CourtOrderEnforcementAgency>
    <ext:ForeignOrderIdentification>
    <nc:IdentificationID/>
    <ext:ForeignOrderIdentificationTypeCode/>
    </ext:ForeignOrderIdentification>
    <ext:HearingHeldIndicator>false</ext:HearingHeldIndicator>
    <nc:Location s:id="DB1618611387">
    <nc:LocationAddress>
    <nc:StructuredAddress>
    <nc:LocationStreet>
    <nc:StreetFullText>3434 Bohnsack Way</nc:StreetFullText>
    <nc:StreetFullText>Unit 75 B</nc:StreetFullText>
    <nc:StreetFullText/>
    </nc:LocationStreet>
    <nc:LocationCityName>New Prague</nc:LocationCityName>
    <nc:LocationStateUSPostalServiceCode>MN</nc:LocationStateUSPostalServiceCode>
    <nc:LocationPostalCode>56071</nc:LocationPostalCode>
    </nc:StructuredAddress>
    </nc:LocationAddress>
    </nc:Location>
    <ext:ProtectedParty>
    <ext:PersonBirthDate ext:approximateDateIndicator="false" ext:currentIndicator="true">1987-11-21</ext:PersonBirthDate>
    <nc:PersonName>
    <nc:PersonGivenName>Jennifer</nc:PersonGivenName>
    <nc:PersonMiddleName>Marie</nc:PersonMiddleName>
    <nc:PersonSurName>O'Brien</nc:PersonSurName>
    <nc:PersonNameSuffixText/>
    <nc:PersonFullName>O'Brien, Jennifer Marie</nc:PersonFullName>
    </nc:PersonName>
    <ext:PersonRaceCode/>
    <nc:PersonSexCode>F</nc:PersonSexCode>
    <ext:PetitionerIndicator>true</ext:PetitionerIndicator>
    </ext:ProtectedParty>
    <ext:ProtectedParty>
    <ext:PersonBirthDate ext:approximateDateIndicator="false" ext:currentIndicator="true">2008-03-24</ext:PersonBirthDate>
    <nc:PersonName>
    <nc:PersonGivenName>Eli</nc:PersonGivenName>
    <nc:PersonMiddleName>Rose</nc:PersonMiddleName>
    <nc:PersonSurName>Noir</nc:PersonSurName>
    <nc:PersonNameSuffixText/>
    <nc:PersonFullName>Noir, Eli Rose</nc:PersonFullName>
    </nc:PersonName>
    <ext:PersonRaceCode/>
    <nc:PersonSexCode>F</nc:PersonSexCode>
    <ext:PetitionerIndicator>false</ext:PetitionerIndicator>
    </ext:ProtectedParty>
    <ext:ProtectionOrderBradyIndicator>N</ext:ProtectionOrderBradyIndicator>
    <ext:ProtectionOrderCondition>
    <ext:ConditionText>Respondent must not have any contact with the Protected Person(s) whether in person, with or through other persons, by telephone, mail, e-mail, through electronic devices, social media, or by any other means except as follows: [] </ext:ConditionText>
    <ext:ConditionCode>08</ext:ConditionCode>
    </ext:ProtectionOrderCondition>
    <ext:ProtectionOrderCondition>
    <ext:ConditionText>Respondent must stay a reasonable distance away from the residence(s) of the Protected Person(s), specifically as follows: [distance]; and Respondent must stay a reasonable distance away from ANY FUTURE RESIDENCES of the Protected Person(s). </ext:ConditionText>
    <ext:ConditionCode>04</ext:ConditionCode>
    </ext:ProtectionOrderCondition>
    <ext:ProtectionOrderCondition>
    <ext:ConditionText>Respondent shall not call or enter Petitioner's place of employment which includes all land, parking lots, and buildings at: </ext:ConditionText>
    <ext:ConditionCode>04</ext:ConditionCode>
    </ext:ProtectionOrderCondition>
    <ext:ProtectionOrderExpirationDate>2015-12-22</ext:ProtectionOrderExpirationDate>
    <ext:ProtectionOrderFinding>
    <ext:FindingText>Respondent personally appeared or had reasonable notice and opportunity to be heard. The procedures for service upon Respondent set forth in the Minnesota Domestic Abuse Act (Minn.Stat. 518B.01) were followed, and the court has jurisdiction over the parties and subject matter. </ext:FindingText>
    <ext:FindingCode>OAH1</ext:FindingCode>
    </ext:ProtectionOrderFinding>
    <ext:ProtectionOrderFinding>
    <ext:FindingText>Acts of domestic abuse have occurred, including the following: [] </ext:FindingText>
    <ext:FindingCode>OAH4A</ext:FindingCode>
    </ext:ProtectionOrderFinding>
    <ext:ProtectionOrderID>1400042</ext:ProtectionOrderID>
    <ext:ProtectionOrderIssuingCourt>
    <nc:OrganizationIdentification>
    <nc:IdentificationID>MN070015J</nc:IdentificationID>
    </nc:OrganizationIdentification>
    <ext:CourtFaxNumber>
    <nc:TelephoneNumberFullID>952-496-8211</nc:TelephoneNumberFullID>
    </ext:CourtFaxNumber>
    <ext:CourtTelephoneNumber>
    <nc:TelephoneNumberFullID>952-496-8200</nc:TelephoneNumberFullID>
    <nc:TelephoneSuffixID/>
    </ext:CourtTelephoneNumber>
    </ext:ProtectionOrderIssuingCourt>
    <ext:ProtectionOrderIssuingDate>2014-12-22</ext:ProtectionOrderIssuingDate>
    <ext:ProtectionOrderIssuingJudicialOfficial>
    <nc:PersonName>
    <nc:PersonGivenName>Do</nc:PersonGivenName>
    <nc:PersonMiddleName>P.</nc:PersonMiddleName>
    <nc:PersonSurName>Ande</nc:PersonSurName>
    <nc:PersonNameSuffixText/>
    <nc:PersonFullName>Ande, Do P.</nc:PersonFullName>
    </nc:PersonName>
    </ext:ProtectionOrderIssuingJudicialOfficial>
    <ext:ProtectionOrderOtherIdentification>
    <nc:IdentificationID>12345</nc:IdentificationID>
    <ext:ProtectionOrderOtherIdentificationTypeCode>NCICNUM</ext:ProtectionOrderOtherIdentificationTypeCode>
    </ext:ProtectionOrderOtherIdentification>
    <ext:ProtectionOrderService>
    <ext:ProtectionOrderServiceAgency>
    <nc:OrganizationIdentification>
    <nc:IdentificationID>MN0191000</nc:IdentificationID>
    </nc:OrganizationIdentification>
    </ext:ProtectionOrderServiceAgency>
    <ext:ProtectionOrderServiceDate>2015-01-10</ext:ProtectionOrderServiceDate>
    <ext:ProtectionOrderServiceTime>16:25:00-06:00</ext:ProtectionOrderServiceTime>
    <ext:ProtectionOrderServiceToCode>Respondent</ext:ProtectionOrderServiceToCode>
    <ext:ProtectionOrderServiceTypeCode>BYPUB</ext:ProtectionOrderServiceTypeCode>
    </ext:ProtectionOrderService>
    <ext:ProtectionOrderService>
    <ext:ProtectionOrderServiceAgency>
    <nc:OrganizationIdentification>
    <nc:IdentificationID>MN0191000</nc:IdentificationID>
    </nc:OrganizationIdentification>
    </ext:ProtectionOrderServiceAgency>
    <ext:ProtectionOrderServiceDate>2015-01-10</ext:ProtectionOrderServiceDate>
    <ext:ProtectionOrderServiceTime>16:25:00-06:00</ext:ProtectionOrderServiceTime>
    <ext:ProtectionOrderServiceToCode>Respondent</ext:ProtectionOrderServiceToCode>
    <ext:ProtectionOrderServiceTypeCode>BYPUB</ext:ProtectionOrderServiceTypeCode>
    </ext:ProtectionOrderService>
    <ext:ProtectionOrderService>
    <ext:ProtectionOrderServiceAgency>
    <nc:OrganizationIdentification>
    <nc:IdentificationID>MN0191000</nc:IdentificationID>
    </nc:OrganizationIdentification>
    </ext:ProtectionOrderServiceAgency>
    <ext:ProtectionOrderServiceDate>2015-01-10</ext:ProtectionOrderServiceDate>
    <ext:ProtectionOrderServiceToCode>Respondent</ext:ProtectionOrderServiceToCode>
    <ext:ProtectionOrderServiceTypeCode>BYPUB</ext:ProtectionOrderServiceTypeCode>
    </ext:ProtectionOrderService>
    <ext:ProtectionOrderService>
    <ext:ProtectionOrderServiceAgency>
    <nc:OrganizationIdentification>
    <nc:IdentificationID>MN0250800</nc:IdentificationID>
    </nc:OrganizationIdentification>
    </ext:ProtectionOrderServiceAgency>
    <ext:ProtectionOrderServiceDate>2015-01-09</ext:ProtectionOrderServiceDate>
    <ext:ProtectionOrderServiceToCode>Respondent</ext:ProtectionOrderServiceToCode>
    <ext:ProtectionOrderServiceTypeCode>BYMAIL</ext:ProtectionOrderServiceTypeCode>
    </ext:ProtectionOrderService>
    <ext:ProtectionOrderService>
    <ext:ProtectionOrderServiceAgency>
    <nc:OrganizationIdentification>
    <nc:IdentificationID>MN0720100</nc:IdentificationID>
    </nc:OrganizationIdentification>
    </ext:ProtectionOrderServiceAgency>
    <ext:ProtectionOrderServiceDate>2014-12-22</ext:ProtectionOrderServiceDate>
    <ext:ProtectionOrderServiceToCode>Respondent</ext:ProtectionOrderServiceToCode>
    <ext:ProtectionOrderServiceTypeCode>BYPUB</ext:ProtectionOrderServiceTypeCode>
    </ext:ProtectionOrderService>
    <ext:ProtectionOrderStatus>
    <ext:ProtectionOrderStatusCode>SBJO</ext:ProtectionOrderStatusCode>
    <ext:ProtectionOrderStatusDate>2014-12-22</ext:ProtectionOrderStatusDate>
    </ext:ProtectionOrderStatus>
    <ext:ProtectionOrderTypeCode>OFP</ext:ProtectionOrderTypeCode>
    <ext:QualifyingRelationship>
    <ext:QualifyingRelationshipCode>LIVTOGTHR</ext:QualifyingRelationshipCode>
    <ext:QualifyingRelationshipText>Lived Together</ext:QualifyingRelationshipText>
    </ext:QualifyingRelationship>
    <ext:Respondent>
    <nc:PersonEthnicityCode/>
    <nc:PersonEyeColorCode/>
    <nc:PersonHairColorCode>XXX</nc:PersonHairColorCode>
    <nc:PersonHeightMeasure>
    <nc:MeasureText>71</nc:MeasureText>
    <nc:MeasureUnitText>inches</nc:MeasureUnitText>
    <nc:LengthUnitCode>INH</nc:LengthUnitCode>
    </nc:PersonHeightMeasure>
    <ext:PersonRaceCode>W</ext:PersonRaceCode>
    <nc:PersonSexCode>M</nc:PersonSexCode>
    <nc:PersonWeightMeasure>
    <nc:MeasureText>210</nc:MeasureText>
    <nc:MeasureUnitText>pounds</nc:MeasureUnitText>
    <nc:WeightUnitCode>LBR</nc:WeightUnitCode>
    </nc:PersonWeightMeasure>
    <ext:AddressReference ext:currentIndicator="true">
    <nc:LocationReference s:ref="DB1618611387"/>
    </ext:AddressReference>
    <ext:PersonBirthDate ext:approximateDateIndicator="true" ext:currentIndicator="false">1990-12-23</ext:PersonBirthDate>
    <ext:PersonBirthDate ext:approximateDateIndicator="false" ext:currentIndicator="false">1989-12-23</ext:PersonBirthDate>
    <ext:PersonBirthDate ext:approximateDateIndicator="false" ext:currentIndicator="true">1991-12-23</ext:PersonBirthDate>
    <ext:PersonName ext:currentIndicator="true">
    <nc:PersonGivenName>Guy</nc:PersonGivenName>
    <nc:PersonMiddleName>Andr</nc:PersonMiddleName>
    <nc:PersonSurName>Noir</nc:PersonSurName>
    <nc:PersonNameSuffixText>Jr.</nc:PersonNameSuffixText>
    <nc:PersonFullName>Noir Jr , Guy Andr</nc:PersonFullName>
    </ext:PersonName>
    </ext:Respondent>
    <ext:RespondentPresentAtHearingIndicator>false</ext:RespondentPresentAtHearingIndicator>
    </ext:ProtectionOrder>
    <ext:SupersededProtectionOrderID xmlns:exc="http://www.courts.state.mn.us/ProtectionOrderServiceExchange/1.0" xmlns:s="http://niem.gov/niem/structures/2.0" xmlns:usps="http://niem.gov/niem/usps_states/2.0"/>
    <ext:Hearing xmlns:exc="http://www.courts.state.mn.us/ProtectionOrderServiceExchange/1.0" xmlns:s="http://niem.gov/niem/structures/2.0" xmlns:usps="http://niem.gov/niem/usps_states/2.0">
    <ext:HearingDateTime>2015-01-20T09:00:00-06:00</ext:HearingDateTime>
    <ext:HearingLocationText>Scott County</ext:HearingLocationText>
    </ext:Hearing>
    </poq:ProtectionOrderQueryResponse>

    Inert to root as first nood.
    http://msdn.microsoft.com/en-us/library/system.xml.xmlnode.insertbefore(v=vs.110).aspx
    Dim doc As New XmlDocument()
    doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" & _
    "<title>Pride And Prejudice</title>" & _
    "</book>")
    Dim root As XmlNode = doc.DocumentElement
    'Create a new node.
    Dim elem As XmlElement = doc.CreateElement("price")
    elem.InnerText = "19.95"
    'Add the node to the document.
    root.InsertBefore(elem, root.FirstChild)
    Console.WriteLine("Display the modified XML...")
    doc.Save(Console.Out)
    remember make the reply as answer and vote the reply as helpful if it helps.

  • How can I use XStream to persist complicated Java Object  to XML & backward

    Dear Sir:
    I met a problem as demo in my code below when i use XTream to persist my Java Object;
    How can I use XStream to persist complicated Java Object to XML & backward??
    See
    [1] main code
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.util.ArrayList;
    import com.thoughtworks.xstream.XStream;
    import com.thoughtworks.xstream.io.xml.DomDriver;
    public class PhoneList {
         ArrayList<PhoneNumber> phones;
         ArrayList<Person> person;
         private PhoneList myphonelist ;
         private LocationTest location;
         private PhoneList(String name) {
         phones = new ArrayList<PhoneNumber>();
         person = new ArrayList<Person>();
         public ArrayList<PhoneNumber> getphones() {
              return phones;
         public ArrayList<Person> getperson() {
              return person;
         public void addPhoneNumber(PhoneNumber b1) {
              this.phones.add(b1);
         public void removePhoneNumber(PhoneNumber b1) {
              this.phones.remove(b1);
         public void addPerson(Person p1) {
              this.person.add(p1);
         public void removePerson(Person p1) {
              this.person.remove(p1);
         public void BuildList(){
              location = new LocationTest();
              XStream xstream = new XStream();
              myphonelist = new PhoneList("PhoneList");
              Person joe = new Person("Joe, Wallace");
              joe.setPhone(new PhoneNumber(123, "1234-456"));
              joe.setFax(new PhoneNumber(123, "9999-999"));
              Person geo= new Person("George Nixson");
              geo.setPhone(new PhoneNumber(925, "228-9999"));
              geo.getPhone().setLocationTest(location);          
              myphonelist.addPerson(joe);
              myphonelist.addPerson(geo);
         public PhoneList(){
              XStream xstream = new XStream();
              BuildList();
              saveStringToFile("C:\\temp\\test\\PhoneList.xml",convertToXML(myphonelist));
         public void saveStringToFile(String fileName, String saveString) {
              BufferedWriter bw = null;
              try {
                   bw = new BufferedWriter(
                             new FileWriter(fileName));
                   try {
                        bw.write(saveString);
                   finally {
                        bw.close();
              catch (IOException ex) {
                   ex.printStackTrace();
              //return saved;
         public String getStringFromFile(String fileName) {
              BufferedReader br = null;
              StringBuilder sb = new StringBuilder();
              try {
                   br = new BufferedReader(
                             new FileReader(fileName));
                   try {
                        String s;
                        while ((s = br.readLine()) != null) {
                             // add linefeed (\n) back since stripped by readline()
                             sb.append(s + "\n");
                   finally {
                        br.close();
              catch (Exception ex) {
                   ex.printStackTrace();
              return sb.toString();
         public  String convertToXML(PhoneList phonelist) {
              XStream xstream = new  XStream(new DomDriver());
              xstream.setMode(xstream.ID_REFERENCES) ;
              return xstream.toXML(phonelist);
         public static void main(String[] args) {
              new PhoneList();
    }[2].
    import java.io.Serializable;
    import javax.swing.JFrame;
    public class PhoneNumber implements Serializable{
           private      String      phone;
           private      String      fax;
           private      int      code;
           private      String      number;
           private      String      address;
           private      String      school;
           private      LocationTest      location;
           public PhoneNumber(int i, String str) {
                setCode(i);
                setNumber(str);
                address = "4256, Washington DC, USA";
                school = "Washington State University";
         public Object getPerson() {
              return null;
         public void setPhone(String phone) {
              this.phone = phone;
         public String getPhone() {
              return phone;
         public void setFax(String fax) {
              this.fax = fax;
         public String getFax() {
              return fax;
         public void setCode(int code) {
              this.code = code;
         public int getCode() {
              return code;
         public void setNumber(String number) {
              this.number = number;
         public String getNumber() {
              return number;
         public void setLocationTest(LocationTest bd) {
              this.location = bd;
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(location);
            f.getContentPane().add(location.getControls(), "Last");
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
         public LocationTest getLocationTest() {
              return location;
         }[3].
    package test.temp;
    import java.io.Serializable;
    public class Person implements Serializable{
         private String           fullname;
           @SuppressWarnings("unused")
         private PhoneNumber      phone;
           @SuppressWarnings("unused")
         private PhoneNumber      fax;
         public Person(){
         public Person(String fname){
                fullname=fname;           
         public void setPhone(PhoneNumber phoneNumber) {
              phone = phoneNumber;
         public void setFax(PhoneNumber phoneNumber) {
              fax = phoneNumber;
         public PhoneNumber getPhone() {
              return phone ;
         public PhoneNumber getFax() {
              return fax;
        public String getName() {
            return fullname ;
        public void setName(String name) {
            this.fullname      = name;
        public String toString() {
            return getName();
    }[4]. LocationTest.java
    package test.temp;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class LocationTest extends JPanel implements ChangeListener
        Ellipse2D.Double ball;
        Line2D.Double    line;
        JSlider          translate;
        double           lastTheta = 0;
        public void stateChanged(ChangeEvent e)
            JSlider slider = (JSlider)e.getSource();
            String name = slider.getName();
            int value = slider.getValue();
            if(name.equals("rotation"))
                tilt(Math.toRadians(value));
            else if(name.equals("translate"))
                moveBall(value);
            repaint();
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            if(ball == null)
                initGeom();
            g2.setPaint(Color.green.darker());
            g2.draw(line);
            g2.setPaint(Color.red);
            g2.fill(ball);
        private void initGeom()
            int w = getWidth();
            int h = getHeight();
            int DIA = 30;
            int padFromEnd = 5;
            line = new Line2D.Double(w/4, h*15/16, w*3/4, h*15/16);
            double x = line.x2 - padFromEnd - DIA;
            double y = line.y2 - DIA;
            ball = new Ellipse2D.Double(x, y, DIA, DIA);
            // update translate slider values
            int max = (int)line.getP1().distance(line.getP2());
            translate.setMaximum(max);
            translate.setValue(max-padFromEnd);
        private void tilt(double theta)
            // rotate line from left end
            Point2D pivot = line.getP1();
            double lineLength = pivot.distance(line.getP2());
            Point2D.Double p2 = new Point2D.Double();
            p2.x = pivot.getX() + lineLength*Math.cos(theta);
            p2.y = pivot.getY() + lineLength*Math.sin(theta);
            line.setLine(pivot, p2);
            // find angle from pivot to ball center relative to line
            // ie, ball center -> pivot -> line end
            double cx = ball.getCenterX();
            double cy = ball.getCenterY();
            double pivotToCenter = pivot.distance(cx, cy);
            // angle of ball to horizon
            double dy = cy - pivot.getY();
            double dx = cx - pivot.getX();
            // relative angle phi = ball_to_horizon - last line_to_horizon
            double phi = Math.atan2(dy, dx) - lastTheta;
            // rotate ball from pivot
            double x = pivot.getX() + pivotToCenter*Math.cos(theta+phi);
            double y = pivot.getY() + pivotToCenter*Math.sin(theta+phi);
            ball.setFrameFromCenter(x, y, x+ball.width/2, y+ball.height/2);
            lastTheta = theta;  // save theta for next time
        private void moveBall(int distance)
            Point2D pivot = line.getP1();
            // ball touches line at distance from pivot
            double contactX = pivot.getX() + distance*Math.cos(lastTheta);
            double contactY = pivot.getY() + distance*Math.sin(lastTheta);
            // find new center location of ball
            // angle lambda = lastTheta - 90 degrees (anti-clockwise)
            double lambda = lastTheta - Math.PI/2;
            double x = contactX + (ball.width/2)*Math.cos(lambda);
            double y = contactY + (ball.height/2)*Math.sin(lambda);
            ball.setFrameFromCenter(x, y, x+ball.width/2, y+ball.height/2);
        JPanel getControls()
            JSlider rotate = getSlider("rotation angle", "rotation", -90, 0, 0, 5, 15);
            translate = getSlider("distance from end",  "translate", 0, 100, 100,25, 50);
            JPanel panel = new JPanel(new GridLayout(0,1));
            panel.add(rotate);
            panel.add(translate);
            return panel;
        private JSlider getSlider(String title, String name, int min, int max,
                                  int value, int minorSpace, int majorSpace)
            JSlider slider = new JSlider(JSlider.HORIZONTAL, min, max, value);
            slider.setBorder(BorderFactory.createTitledBorder(title));
            slider.setName(name);
            slider.setPaintTicks(true);
            slider.setMinorTickSpacing(minorSpace);
            slider.setMajorTickSpacing(majorSpace);
            slider.setPaintLabels(true);
            slider.addChangeListener(this);
            return slider;
    }OK, My questions are:
    [1]. what I generated XML by XSTream is very complicated, especially for object LocationTest, Can we make it as simple as others such as Person object??
    [2]. after I run it, LocationTest will popup and a red ball in a panel will dsiplay, after I change red ball's position, I hope to persist it to xml, then when I read it back, I hope to get same picture, ie, red ball stiil in old position, How to do that??
    Thanks a lot!!

    Positive feedback? Then please take this in a positive way: if you want to work on persisting Java objects into XML, then GUI programming is irrelevant to that goal. The 1,000 lines of code you posted there appeared to me to have a whole lot of GUI code in it. You should produce a smaller (much smaller) example of what you want to do. Calling the working code from your GUI program should come later.

  • Dynamically create Value Objects from XML file

    Hi
    I want to create a value object from Xml file dynamically,like in the xml file i have the name of the variable and the datatype of the variable.is it possible do that,if so how.

    Read about apache's Digester tool. This is part of the Jakartha project. This tool helps in creating java objects from the XML files. I am not sure, if that is what u r looking for.

  • How do I check if section and subdivision exist inside object's xml?

    My function is working but not as I expect it to. The problem is that when Section and Subvision are not found in the object aobjXmlGetStatuteRequestNode xml, I get an error NullReference Exception was unhandled by user code. Object reference not set
    to an instance of an object. 
    For that reason, because the two elements are optional, I would like to check if they exist before adding their value into the xml inside the object objXmlRequestMessageDoc.
    The if statement I used in my function did not work. When it found Section element, it did not check for Subdivision. 
    How do I check for both and add them if they exist. If they do not exist, I do not need to do anything and should not throw an error since they are optional.
     Object aobjXmlGetStatuteRequestNode has this xml
    <ns:GetStatutesRequest xmlns:ns="http://www.courts.state.mn.us/StatuteService/1.0">
    <ns:Statute>
    <ns:Chapter>169</ns:Chapter>
    <!--Optional:-->
    <ns:Section>191</ns:Section>
    <!--Optional:-->
    <ns:Subdivision>a</ns:Subdivision>
    </ns:Statute>
    The following output in the objXmlRequestMessageDoc object is correct but this does not work when Section and or Subdivision are not found in the object aobjXmlGetStatuteRequestNode.
    <ns:BasicSearchQueryRequest xmlns:ns="http://crimnet.state.mn.us/mnjustice/statute/service/4.0">
    <ns1:BasicSearchCriteria xmlns:ns1="http://crimnet.state.mn.us/mnjustice/statute/messages/4.0">
    <ns2:Chapter xmlns:ns2="http://crimnet.state.mn.us/mnjustice/statute/4.0"/169</ns2:Chapter>>
    <ns2:Section xmlns:ns2="http://crimnet.state.mn.us/mnjustice/statute/4.0"/>191</ns2:Chapter>
    <ns2:Subdivision xmlns:ns2="http://crimnet.state.mn.us/mnjustice/statute/4.0"/>a</ns2:Chapter>
    </ns1:BasicSearchCriteria>
    </ns:BasicSearchQueryRequest>
    My Function
    Function GetStatutesByChapter(ByVal aobjXmlGetStatuteRequestNode As XmlNode, ByVal aobjXMLNameSpaceManager As XmlNamespaceManager, ByVal aobjBroker As ServiceCatalog.Library.v4.Broker) As XmlDocument
    Dim objXmlRequestMessageDoc As XmlDocument
    Dim objXmlResponseMessageDoc As XmlDocument
    Dim intCount As Integer
    aobjBroker.PostMessageWarehouseInformationalMessage("Chapter found.", 1)
    objXmlResponseMessageDoc = New XmlDocument
    'Add the first element into the document GetStatuteByChapter with its namespace
    objXmlResponseMessageDoc.AppendChild(objXmlResponseMessageDoc.CreateElement("BasicSearchQueryResponse", "http://crimnet.state.mn.us/mnjustice/statute/service/4.0"))
    'Create the BCA request message
    objXmlRequestMessageDoc = New XmlDocument
    objXmlRequestMessageDoc.AppendChild(objXmlRequestMessageDoc.CreateElement("ns:BasicSearchQueryRequest", aobjXMLNameSpaceManager.LookupNamespace("ns")))
    objXmlRequestMessageDoc.SelectSingleNode("ns:BasicSearchQueryRequest", aobjXMLNameSpaceManager).AppendChild(objXmlRequestMessageDoc.CreateElement("ns1:BasicSearchCriteria", aobjXMLNameSpaceManager.LookupNamespace("ns1")))
    objXmlRequestMessageDoc.SelectSingleNode("ns:BasicSearchQueryRequest/ns1:BasicSearchCriteria", aobjXMLNameSpaceManager).AppendChild(objXmlRequestMessageDoc.CreateElement("ns2:Chapter", aobjXMLNameSpaceManager.LookupNamespace("st")))
    objXmlRequestMessageDoc.SelectSingleNode("ns:BasicSearchQueryRequest/ns1:BasicSearchCriteria", aobjXMLNameSpaceManager).AppendChild(objXmlRequestMessageDoc.CreateElement("ns2:Section", aobjXMLNameSpaceManager.LookupNamespace("st")))
    objXmlRequestMessageDoc.SelectSingleNode("ns:BasicSearchQueryRequest/ns1:BasicSearchCriteria", aobjXMLNameSpaceManager).AppendChild(objXmlRequestMessageDoc.CreateElement("ns2:Subdivision", aobjXMLNameSpaceManager.LookupNamespace("st")))
    objXmlRequestMessageDoc.DocumentElement.SelectSingleNode("ns1:BasicSearchCriteria/st:Chapter", aobjXMLNameSpaceManager).InnerText = aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Chapter", aobjXMLNameSpaceManager).InnerText
    objXmlRequestMessageDoc.DocumentElement.SelectSingleNode("ns1:BasicSearchCriteria/st:Section", aobjXMLNameSpaceManager).InnerText = aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Section", aobjXMLNameSpaceManager).InnerText
    objXmlRequestMessageDoc.DocumentElement.SelectSingleNode("ns1:BasicSearchCriteria/st:Subdivision", aobjXMLNameSpaceManager).InnerText = aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Subdivision", aobjXMLNameSpaceManager).InnerText
    'check if there is a section and or subdivision if it is there then set the value
    'If Not (aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Section", aobjXMLNameSpaceManager).InnerText) Is Nothing Then
    ' objXmlRequestMessageDoc.DocumentElement.SelectSingleNode("ns1:BasicSearchCriteria/st:Section", aobjXMLNameSpaceManager).InnerText = aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Section", aobjXMLNameSpaceManager).InnerText
    'End If
    'check if there is a section and or subdivision if it is there then set the value
    aobjBroker.PostMessageWarehouseSnapshot(objXmlRequestMessageDoc.OuterXml, "Request Message", 1)
    'Call the BCA service
    intCount = 0
    'Count how many Statute node found
    CType(objXmlResponseMessageDoc.SelectSingleNode("ss:GetStatutesResponse/ss:StatutesXml/ss:Statutes", aobjXMLNameSpaceManager), System.Xml.XmlElement).SetAttribute("totalCount", CStr(intCount))
    Return objXmlResponseMessageDoc
    End Function

    I have resolved this issue by using two if statements as follows
    'check if there is a section and or subdivision if it is there then set the value
    If Not (aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Section", aobjXMLNameSpaceManager) Is Nothing) Then
    objXmlRequestMessageDoc.DocumentElement.SelectSingleNode("ns1:BasicSearchCriteria/st:Section", aobjXMLNameSpaceManager).InnerText = aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Section", aobjXMLNameSpaceManager).InnerText
    End If
    If Not (aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Subdivision", aobjXMLNameSpaceManager) Is Nothing) Then
    objXmlRequestMessageDoc.DocumentElement.SelectSingleNode("ns1:BasicSearchCriteria/st:Subdivision", aobjXMLNameSpaceManager).InnerText = aobjXmlGetStatuteRequestNode.SelectSingleNode("ss:Statute/ss:Subdivision", aobjXMLNameSpaceManager).InnerText
    End If

  • How to map more than one xml element with some Paragraph in a Text Frame

    Hi friends,
    I am new in InDesign Java Scripting and I have to place or map, more than one xml elements of different parents, into one textbox. Is it possible through JavaScript? Can anyone help me in this because I have no idea how it should work and it urgently required.
    Thanks in Advance

    I had answered to you already in your first post: the short answer is that it's not possible on the same text box unless you assign a common ancestor of these two "parents" item. That's not a question of scripting, it's the way Indesign handle the XML with the layout. Import a xml in Indesign and drop tags to page item. What you can do manually is quite representative of what can be done through scripting.
    If you assign this anscestor to the text frame, you have to expect that all text child items will be displayed in the text frame (including the text of all the child of the two "parents" and all the other parents/childs that could be under the common ancestor). Having a XML that is designed for Indesign usage is pretty much inevitable if you are doing anything "serious".

  • Mapping java classes to XML files

    Hi Friends !!
    Please I need your help.
    Does somebody out there know any framework or API that helps me to map Java classes to XML files.
    Something like:
    public class Test {
        public int x;
        public int y;
        public int sum(){}
    }to something like:
    <?xml version="1.0" encoding="UTF-8"?>
    <class>
    <className>Test</className>
    bla
    bla
    bla
    </class>
    Any tips?
    Thanks in advance
    Cleverson

    JAXB will create classes from an XML schema, SAX is a parser library and JAXP is a library of XML a bunch of XML tools.
    I don't care for JAXB too much. I would skip it and go right to the JAX-RPC spec (WebServices).

  • Mapping Value Objects to Java Classes

    Hi All,
    I have one Java Class:
    public class MyBean {
        private ArrayList numbers;
    I have created one mapping value object for the same in Flex:
    package vo
        import mx.collections.ArrayCollection;
        [RemoteClass(alias="com.tcs.example.MyBean")]
        public class MyBean
            public function MyBean()
            public var numbers:ArrayCollection;
    but when I fetch the object using Remote Object, the returned object has "numbers" as null even though I'm returning from Java a filled ArrayList.
    Does any one know Why is it happening and what should I do for this.
    Thanks in advance

    Do you have getNumbers and setNumbers methods on your java bean?
    Try to activate the logs on blazeDS to see what's going on.

  • Objects to XML

    I use XStream to parse the following Objects to XML, the problem is what to do with:
    class Tag {
    @XStreamAsAttribute
    List<SubTag1> st1 = new ArrayList<SubTag1>();
    @XStreamAsAttribute
    List<SubTag2> st2 = new ArrayList<SubTag2>();
    ...When the class Tag is converted to XML it will always contain both a 'st1' and 'st2' even when I only
    have a Tag that ONLY contains 'st1'.
    Tag should be able to contain:
    1) List of SubTag1
    or
    2) List of SubTag2
    or
    3) List of SubTag1 and List of SubTag2
    How do I make sure to only process the Lists if they contains elements?

    Looks like you need a converter, for more info you could try the [XStream mailing list|http://xstream.codehaus.org/list-user.html].

  • How to map jsp in web.xml

    Hi,
    CAn anybody tell me that how to map .jsp in web.xml
    thanx
    vjoy

    Same as servlets, except that you specify jsp-file in place of servlet-class - see below
      <servlet>
         <servlet-name>MyJspServlet</servlet-name>
         <jsp-file>/jspServlet.jsp</jsp-file>
      </servlet>
      <servlet-mapping>
         <servlet-name>MyJspServlet</servlet-name>
         <url-pattern>/myJspServlet</url-pattern>
      </servlet-mapping>cheers,
    ram.

Maybe you are looking for

  • How to use the km Discussion iViews in the enterprise portal

    hi , i need to create a discussion forum in the EP. i want to make a KM discussion iview and then to customize it so that the look and feel is also changed. i am not getting how should i start?Is PDK development needed for this? please help.

  • How to Uninstall a ST-PI 2008_1_46C Plug in Hotpack

    I have installed ST-PI 2008_1_46C on our system and now when I am doing a prepare for upgrade to Ecc6 SR2, it is giving me warning that my ST-PI is greater that 2005_1_46C, which can cause problem in IS_SELECT phase. Is their a way to uninstall the S

  • Imovie crashed every time I try to export... Help!?!

    Imovie crashes when I try to export the movie I have made. I have tried in many different formats... And I have tried to restart, update and everything but nothing works... Please help!!!!!! I spend many hours on this project, but now I cannot finish

  • WRT300N support for multiple XBOX 360's

    Hi! I need to go pre-N for greater wireless speeds, and went for the Belkin Pre-N v2000; however it's uPNP implementation isn't that great, meaning I need to rely on DMZ to allow my XBOX 360 to work on LIVE. What I would like to know is does the WRT3

  • Lightroom 4 full version

    I purchased Lightroom 4, full verison, in the box, still factory sealed. However upon install, Adobe tells me the serial number is in use by another owner and is for CS4, not lightroom. Since it is the full retail box, still sealed in cellophane, how