JAXB: How to unmarshal from xml contains two schemas?

Hi, all.
My question is in subject.
Ex.)
schema1.xsd:
(snip)...
<xsd:element name="xxx">
<xsd:complexType>
<xsd:sequence>
<xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
...(snip)
schema2.xsd:
(snip)...
<xsd:element name="yyy">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="zzz" minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="zzz" type="xsd:string"/>
if I have a xml like the following, xml validation is correct:
sample.xml:
(snip)...
<ns1:xxx xmlns:ns1="...(schema1.xsd)...">
<ns2:yyy xmlns:ns2="...(schema2.xsd)...">
<ns2:zzz>SAMPLE</ns2:zzz>
</ns2:yyy>
</ns1:xxx>
I want to unmarshal from this xml using JAXB, but actually ths xxx didn't have any tag in List class given getAny() method, because xxx doesn't know about yyy, I think.
These schemas cannot change as requirements of customer.
How to unmarshal from xml contains two schemas using JAXB?
tx.

I solved it myself.
JAXBContext can be specified many context path at same time.
Ex.)
context = JAXBContext.newInstance("package1:package2:package3...");
So, unmarshaller can know how to choose what be instanced.
tx.

Similar Messages

  • How to convert from XML to Array ?

    how to convert from XML to Array ?
    thanks in advance

    this is a segment of the xml object:
    var myXML:XML =
    <data>
    <task>
    <taskID>2</taskID>
    <startDate>2/15/2007</startDate>
    </task>
    </data>
    i want to conver myXML into ArrayCollection: like this:
    private var expenses:Array = [
    {taskID:"1", startDate:"2/15/2007"},
    {taskID:"2", startDate:"4/15/2007"}
    how i can do it ? and tell me how to retrieve the data from
    the collection
    thanks

  • How to convert from xml file to html using java code

    How to convert from xml file to html file using java code

    Get yourself Apache Xalan or Saxon or some XSLT processor
    String styleSheet = "/YourXSLTStylesheet.xsl";
    String dataSource = "/YourXMLDocument.xml";
    InputStream stylesheetSource = TransformMe.class.getResourceAsStream(styleSheet);
    InputStream dataSourceStream = TransformMe.class.getResourceAsStream(dataSource);
    OutputStream transformedOut = new FileOutputStream("filename.html");
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer(new StreamSource(stylesheetSource));
    transformer.transform(new StreamSource(dataSourceStream), new StreamResult(transformedOut));You'll also need to learn XSLT if you don't already know that. Here's a good place to start
    http://www.w3schools.com/xsl/

  • JAXB:  How do I add xml declaration?

    Hi there
    How do I add <?xml-stylesheet ... > while constructing a JAXB object befor the marshalling process?
    Please help?
    Thanks
    ~Glen

    Hi there
    How do I add <?xml-stylesheet ... > while constructing
    a JAXB object befor the marshalling process?
    Please help?
    Thanks
    ~GlenIf you see there is an example on xml-stylesheet in the jaxb1.0
    bundle.
    That will show you how to insert the xml-stylesheet in your processingInstruction.
    Thanks,
    Bhakti

  • How to create an XML Oracle database schema

    Hello, I would like to generate an XML file that contains the schema of my Oracle database so that I can reference one file for column names and table names. I do not need any data from the tables, just the basic layout: e.g. table names, their respective column names.
    Obviously, I would like the ability to generate this file each time we make changes to our DB, so its generation will be an ongoing process.
    My question is, what is the best tool for this? Or the most widely accepted? Can anyone help with this?

    To get database metadata as XML use Oracle Web RowSet.
    //Import the oracle.jdbc.rowset package classes.
    import oracle.jdbc.rowset.*;
    //Import the RowSetMetaDataImpl class.
    import javax.sql.rowset.RowSetMetaDataImpl;
    //Create a OracleWebRowSet class.
    OracleWebRowSet webRowSet=new OracleWebRowSet();
    /*Set the datasource name to obtain a JDBC connection with the database. The datasource name is configured in the data-sources.xml file. */
    webRowSet.setDataSourceName("jdbc/OracleDataSource");
    //Set the SQL query command for the OracleWebRowSet class object.
    webRowSet.setCommand(selectQuery);
    selectQuery is a SQL command variable which is input from a JSP.
    //Set the username and password to obtain a JDBC connection.
    webRowSet.setUsername("OE");
    webRowSet.setPassword("<password>");
    //Set the read only, fetch size and max rows attributes of the OracleWebRowSet object.
    webRowSet.setReadOnly(false);
    webRowSet.setFetchSize(5);
    webRowSet.setMaxRows(3);
    //Run the SQL command specified in the setCommand() method.
    webRowSet.execute();
    /*A Web RowSet gets created consisting of the data retrieved from the database table with the SQL query.  Generate an XML document from the WebRowSet.*/
    OutputStreamWriter output=new OutputStreamWriter( new
    FileOutputStream(new File("c:/output/output.xml")));
    webRowSet.writeXml(output);

  • ORA-20100: Error occurred while parsing (from xml in custom schema)

    Hi,
    I am using xmlParser and xmlDom to extract information from xml document. My whole process works perfectly in the APPS schema on the Oracle e-Business Suite. The minute I move it to a custom schema (ie new User) I get this error.
    ORA-20100: Error occurred while parsing: Element '' used but not declared.
    This only occures at runtime. I am pretty sure I grant the correct SELECT and EXECUTE privileges to this Schema. If I hadn't then it would not compile. It compiles without errors on the Database.
    Any help will be appreciated.
    Thanks in advance.
    Regards
    Dave

    I just tried this again. I have Oracle9i 9.0.1.1 on my Windows
    2000 laptop.
    I went to OTN and downloaded the XDK 9.0.2D for PL/SQL
    I used loadjava to load the \oracle\ora90\rdbms\jlib\xdb_g.jar
    file into the database (shouldn't have had to do this) into the
    XMLBOOK account. Filed a bug for needing to do this by hand.
    I ran "xdkload.bat" with xmlbook/xmlbook as the username/password
    I made sure the proxy server name was set correctly in the
    example (if you don't need a proxy server, comment out that line
    in the parse_xml_news.sql example, or that could cause your
    error!!)
    I ran the parse_xml_news.sql script, and I get:
    Top Stories on XML from Moreover.com on December 21st, 2001
    ( 1) CEO highlights Mercator Softwares single biggest opportunity
    ( 2) WWRE Chooses webMethods
    ( 3) WebMethods, retail exchange ink deal
    ( 4) Worldwide Retail Exchange Chooses webMethods
    ( 5) Worldwide Retail Exchange Chooses webMethods
    ( 6) WorldWide Retail Exchange choses webMethods for integration
    ( 7) XML: Wherever You Go, There You Are
    ( 8) Chap. 13: Metadata
    ( 9) Enterprise Adoption of XML Made Simple
    (10) XML Databases
    (11) Using CSS2 to display XML documents
    (12) How XML could bring an end to all of your troubles
    (13) Effort Launched To Bring Classic Macs Rich Metadata To Mac
    (14) Sneak attack on Pearl Harbor roused publics anger, resolve
    (15) Drug dogs whiff worth $230,000
    (16) PORTLAND Police target
    (17) 11-year-old cant seem to get out of jury duty
    (18) Another casualty of war: Proposed waterfront museum
    (19) webMethods Establishes Sales Operations in Brussels
    (20) Using Emacs for XML documents
    (21) Gates: XML could be everything we dreamed...
    (22) XML: The end of all your troubles?
    (23) Java XML
    (24) Tool To Compare XML Files
    (25) Fairfax County Sends webMethods to School
    (26) webMethods Embraces Web Services
    (27) WebMethods Supports Web Services
    (28) Accessing metadata through Reflection
    (29) When format is foremost
    (30) Views from Abroad: XML Pipelines and Delta XML

  • How to map from XML(xsd) to Service

    Hi ,
    when i try to map from generated Xml to Service input i am getting below error like
    Failed to load "" type. 
     Please verify the fully-qualified type name is valid.
     Details: "".
     The type must derive from System.Web.Services.Protocols.SoapHttpClientProtocol.
     The type must have the attribute System.Web.Services.WebServiceBindingAttribute. 
    thanks in advance
    Chinna

    Hi Ram, thanks for ur reply,
    here i am sending multple fields data to <any> element typebecause of source will change every time in source data stucture type is 
    <root xmlns:apl='http://www.xxxx.in' xmlns:atl='http://www.xxxx.in/atl'>
        <product apl:entity='Product' apl:onNew='' apl:match='database.byId(id, Product)'>
            <id>id</id>
            <name>name</name>
            <external-id>externalId</external-id>
            <parent-id>string i:parent=database.byId(i, Product)</parent-id>
            <accounting-symbol>accountingSymbol</accounting-symbol>
            <long-name>alternativeName</long-name>
            <description>description</description>
            <is-closed>isClosed</is-closed>
            <accounting-code-purchase>accountingCodePurchase</accounting-code-purchase>
            <accounting-code-sale>accountingCodeSale</accounting-code-sale>
        </product>
        <apl:reply>
            <ImportAcknowledgement>
                <atl:repeat select="database.updatedItems">
                    <product>
                        <id>{id}</id>
                        <external-id>{item.externalId}</external-id>
                        <success>{successful}</success>
                        <message>{error}</message>
                    </product>
                </atl:repeat>
            </ImportAcknowledgement>
        </apl:reply>
    </root>
    in map i used masscopy functoid to map from Source Document root to destination Document root field.
    the above total data is sent to destination. destination structre is 
    RootNode
    TemplateId
    TemplateName
    Document
    <Any>
    after in logical ports i used to select existing ports and i deployed and in Bts admin i used SOAP adapter for sending the requset to Webservice . 
    here in this process iam getting the above error.
    thanks
    chinna

  • How to publish from iWeb to two different .mac accounts

    my household has two separate .macs account and we want to publish from iWeb to the two different accounts which I cannot figure out. thanks

    I discovered I could duplicate Domain.sites2 (~/Library/Application Support/iWeb/Domain.sites2). I named one "Domain de.sites2", and the other "Domain daru.sites2". Then I opened daru's site and deleted de's, then I opened de's and deleted daru's, and I have two separate sites (with aliases in the dock) that I presume I'll be able to upload separately. Once I get .Mac sub groups created...
    If it works, it saves the hassle of creating other user accounts, since only my wife and I use the computer. Right now, .Mac is telling me I can't create a sub account in my wife's name because she already has a .Mac ID (and a two month free trial account she had to agree to, to join the group) for a group site I manage. I don't think she ought to be required to have a separate identity every time she logs into .Mac.
    Daru

  • How to increment array that contains two clusters whose visibility is controlled by a visible property node and selected by a radio button.

    I am trying to use a property node: visible in order to enable or disable one of two clusters. These clusters are in a larger cluster and this larger cluster is in an array. The two clusters are controlled by a radio button (one labeled transistor and the other diode). When diode is selected, the corresponding diode parameters cluster should be visible and when transistor is selected, the corresponding transistor parameters cluster should be visible. In the mean time, the cluster of the device that is not selected should not be visible. There are at least 45 elements in the array (but not more than 45). Data is entered into each cluster (diode or transistor data) for each element in the array via the increment/decrement. The problem is when you select the first radio button (transistor) and enter data, when you increment the array for a new device selection, since a visible property node was used on the cluster, a loop is created where a new cluster is trying to be shown, but the old cluster is also trying to be shown (because it is the one referenced by the property node. How do I get rid of this loop and still be able to increment the array and keep my data intact for future use? Attached is the vi
    Attachments:
    ChooseScan.vi ‏17 KB

    You could try something like this.  However, if you know how to use an xcontrol, that would be a better way to implement the above functionality so that these UI characteristics are not a part of your main VI.  The problem with the above VI is that you're looping every 100 ms just to update your UI.
    Also, try using the "disabled" property node, instead of the "visible" one.  That way, the user will still see the options he has but they will be grayed out.
    Message Edited by Sudhir Gopinath on 06-25-2007 04:45 PM
    S G
    Certified LabVIEW Architect, Certified TestStand Developer, Certified Professional Instructor
    Attachments:
    ChooseScan_1.vi ‏19 KB

  • Retrieving data from XML containing namespaces?

    Hi,
    I am using Yahoo Local Search Service which returns the XML
    response. I want to retrieve data from the XML that I received. I
    stuck at this point and unable to retrieve the response in to
    datagrid. Does the namespaces in XML matter while retrieving data?
    The response XML is as follows
    <ResultSet xsi:schemaLocation="urn:yahoo:lcl
    http://api.local.yahoo.com/LocalSearchService/V3/LocalSearchResponse.xsd"
    totalResultsAvailable="224" totalResultsReturned="1"
    firstResultPosition="1" xmlns:xsi="
    http://www.w3.org/2001/XMLSchema-instance"
    xmlns="urn:yahoo:lcl">
    <ResultSetMapUrl>
    http://maps.yahoo.com/broadband/?q1=San+Jose%2C+CA+95112&amp;tt=starbucks&amp;tp=1</Result SetMapUrl>
    <Result id="21590724">
    <Title>Starbucks</Title>
    <Address>145 W Santa Clara St</Address>
    <City>San Jose</City>
    <State>CA</State>
    <Phone>(408) 288-8803</Phone>
    <Latitude>37.335236</Latitude>
    <Longitude>-121.892765</Longitude>
    <Rating>
    <AverageRating>4</AverageRating>
    <TotalRatings>3</TotalRatings>
    <TotalReviews>2</TotalReviews>
    <LastReviewDate>1198029377</LastReviewDate>
    <LastReviewIntro>My previous review had incorrect
    data. That was not true, I am sorry, I didn't know. As far as food
    and drink goes, Starbucks is pretty good.</LastReviewIntro>
    </Rating>
    <Distance>0.96</Distance>
    <Url>
    http://local.yahoo.com/info-21590724-starbucks-san-jose</Url>
    <ClickUrl>
    http://local.yahoo.com/info-21590724-starbucks-san-jose</ClickUrl>
    <MapUrl>
    http://maps.yahoo.com/maps_result?q1=145+W+Santa+Clara+St+San+Jose+CA&amp;gid1=21590724</M apUrl>
    <BusinessUrl>
    http://www.starbucks.com/</BusinessUrl>
    <BusinessClickUrl>
    http://www.starbucks.com/</BusinessClickUrl>
    <Categories>
    <Category id="96926219">Cafes</Category>
    <Category id="96926236">Restaurants</Category>
    <Category id="96926169">Coffee Houses</Category>
    </Categories>
    </Result>
    </ResultSet>
    The code that I am writing to get Title and Address is as
    follows.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="vertical"
    backgroundAlpha="0" backgroundColor="#FFFFFF">
    <mx:HTTPService
    id="weatherService"
    url="
    http://local.yahooapis.com/LocalSearchService/V3/localSearch"
    resultFormat="e4x"
    result="resultHandler(event);"/>
    <mx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection;
    import mx.rpc.events.ResultEvent;
    [Bindable]
    private var myResult:XML ;
    private var temp:XMLNode;
    private var list:ArrayCollection;
    public function requestWeather():void {
    weatherService.cancel();
    var params:Object = new Object();
    params.appid = "YahooDemo";
    params.query = "starbucks";
    params.zip = "95112";
    params.results = "1"
    weatherService.send(params);
    public function resultHandler(event:ResultEvent):void {
    myResult = XML( event.result);
    temp = myResult.Result;
    list = ArrayCollection(event.result);
    ]]>
    </mx:Script>
    <mx:Form width="400">
    <mx:FormItem label="Get Local Data">
    <mx:Button label="Get Data"
    click="requestWeather();"/>
    </mx:FormItem>
    <mx:FormItem label="Address">
    <mx:Text text="{myResult.Result.Address}"/>
    </mx:FormItem>
    <mx:FormItem label="Title">
    <mx:Text text="{myResult.Result.Title}"/>
    </mx:FormItem>
    </mx:Form>
    <mx:DataGrid
    dataProvider="{myResult.Result}"
    x="80" y="141" width="262" height="92"
    id="shippingOptionsList" editable="false" enabled="true">
    <mx:columns>
    <mx:DataGridColumn headerText="Title" dataField="Title"
    />
    <mx:DataGridColumn headerText="Address"
    dataField="Address" />
    </mx:columns>
    </mx:DataGrid>
    <mx:Label text="Response as it is"/>
    <mx:TextArea id="resultFld" text="{myResult}" width="400"
    height="152"/>
    </mx:Application>
    Can somebody help me to find where I am going wrong?
    Thank you
    -Pranay

    Hi Pranay,
    It looks like your problem is indeed to do with the XML
    namespace being used.
    Try adding this line after the import statements:
    namespace yahoo = "urn:yahoo:lcl";
    (This is the namespace URI defined in the returned XML)
    The result handler should then look like this:
    public function resultHandler(event:ResultEvent):void {
    use namespace yahoo;
    myResult = XML( event.result);
    temp = myResult.Result;
    list = ArrayCollection(event.result);

  • How to unmarshal large XML file

    I have a large (170 MB) XML document. The size is due to a complex tree structure that is an array. It's taking approximately 45 minutes to unmarshal the document into the OTD. Not sure if there's a way to process this XML document in pieces (logical section)?? Suggestions are appreciated.

    I tried your suggestion, but get an error when I try to export the XSD node. It's expecting a TargetNamespace. Here is the beginning of the XSD that I imported:
    <?xml version="1.0" encoding="utf-8"?>
    <xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="MeterReadingDocument" nillable="true" type="MeterReadingDocument" />
    <xs:complexType name="MeterReadingDocument">
    <xs:complexContent mixed="false">
    <xs:extension base="XmlDocumentBase">
    <xs:sequence>
    <xs:element minOccurs="0" maxOccurs="1" name="Remarks" type="ArrayOfString" />
    <xs:element minOccurs="0" maxOccurs="1" name="Header" type="ExportHeader" />
    <xs:element minOccurs="0" maxOccurs="1" name="ImportExportParameters" type="ImportExportParameters" />
    <xs:element minOccurs="0" maxOccurs="1" name="Channels" type="ArrayOfChannel" />
    </xs:sequence>
    </xs:extension>
    </xs:complexContent>
    </xs:complexType>
    If I add a targetNamespace, then I get an exception when I attempt to unmarshal the file. I get the message:
    There was an error during unmarshal.
    Expect: '{http://www.w3.org/2001/XMLSchema}MeterReadingDocument', found: 'MeterReadingDocument'
    Not sure what to do.
    Thanks.

  • How to read from xml documents using either sax or dom

    dear all
    i have an xml document and i want to create a procedure to read the data from it .
    is it possible or not? thanks in advance

    Where is the xml document located?
    load it into an XMLTYPE and apply xpath as required.
    SQL> declare
      2    xml xmltype ;
      3  begin
      4    xml := xmltype('<node><value>this is text</value></node>') ;
      5    dbms_output.put_line('value='||xml.extract('/node/value/text()').getStringVal()) ;
      6  end ;
      7  /
    value=this is text
    PL/SQL procedure successfully completed.
    SQL>

  • How to recover from XML gateway error when generating outbound message

    Hi,
    Due to a misconfiguration in other part of the system, our Purchase Order Request map (RosettaNet PIP3A4) failed on few dozen of orders and ended with an error.
    How can we restart the process and retry the map generation in XML Gateway (as now the problem is fixed)?
    Many thanks in advance,
    Regards
    Kamil

    Hi Kamil;
    please check below and see its helpful:
    http://download.oracle.com/docs/cd/B31017_01/core.1013/b28764/esb002.htm
    http://download-uk.oracle.com/docs/cd/B31017_01/integrate.1013/b28211.pdf
    Regard
    Helios

  • How to structure an XML doc using schema?

    Hi there,
    I have an XML file with a grouped <employee> tags like,
    <employee>
    <employeename>John</employeename>
    <employeename>Dave</employeename>
    </employee>
    I want to structure above xml file to be like this
    <employee>
    <employeename>John</employeename>
    </employee>
    <employee>
    <employeename>Dave</employeename>
    </employee>
    Can I do that in a XML schema (.xsd file)? If I can, how do I do that?
    Thanks,
    Chandi

    Hi Dave,
    Thanks for your response.
    I create this XML from .xsd files using a tool (MapForce by Altova which allows me to do the mappings between relational database table columns and elements in the .xsd file, and it creates Java code for me), the data is read from a database to compose this XML file.
    Everything works fine with this XML file, I just want to change the structure of the XML file when it composes it, I was wondering if I could do that by changing the existing .xsd file?
    Its not easy to use XSLT, I�m dealing with over 600 hierarchical elements with over 15 .xsd files.
    So, what are my options?
    All I want to know is, what should I change in the .xsd in order to compose this XML in the structure that I want.
    It groups all the employee names (<employeename> tag) under one <employee> tag, instead I want to have individual <employee> tags for each and every <employeename> tags (<employee> tag around <employeename> tag for each and every employee)
    Is it possible at all?
    Thanks,
    Chandi

  • How to validate an xml with a schema w/o specifying the schema in the xml

    I have done xml validation with xml schemas, where the xml points to the xsd to use. However, I would like to not have to specifiy the xml schema in the xml document (and can't ensure that the xml coming to us has that in it). How do I, in the java code, tell it what schema to use in validation?
    Brian

    static final String schemaSource = argv[0];
    static final String JAXP_SCHEMA_SOURCE =
    "http://java.sun.com/xml/jaxp/properties/schemaSource";
    DocumentBuilderFactory factory =
    DocumentBuilderFactory.newInstance();
    factory.setAttribute(JAXP_SCHEMA_SOURCE,
    new File(schemaSource));

Maybe you are looking for

  • Distributed Portal - Firewall - Visibroker Gatekeeper

    Environment: Distributed portal configuration where the mid-tier is outside the firewall and infrastructure is inside the firewall. Question : Can we use Visibroker Gatekeeper (one which comes with Discoverer 4i) so that we do not have to open numero

  • Open hub services and infospokes

    I am quite new to BW,i like to know about open hub services and what are infospokes and it is used to implement open hub services.i will b happy if u can provide some materials as well.

  • ITunes Store Available for Purchases, but "Unavailable" when Downloading?

    Is anyone else having troubles with purchases from the iTunes Store? I've browsed, sampled music, accessed my account all without any problem. It even processed my purchase and charged me for it, complete with receipt. However, the purchase stays in

  • Do you also crash Preview  when opening scanned document pdf file?

    I recently crashed Mail when opening a message coming from my IAP with an attached pdf file. The cause is a crash of preview.app that I can repeat. Therefore the file (a scanned document) can be opened by Acrobat Reader. I found in some forum that Ac

  • SLD error in Installation Number

    Hi colleagues, I have install de SLD in the Portal 2004S. I connect to the http://server:50000/sld. When try configure my System Landscape, in the Installation Number I have a error. The error is  "Installation number must have exaclty 10 digits, or