Jaxb and container elements

Hi,
Consider this XML:
<container>
<items>
<item/>
<item/>
<item/>
<!-- ... -->
</items>
</container>
as of now, to get a list of items I need to make two calls: the first to get the object corresponding to the <items> element, and the second to get the actual items (e.g. container.getItems().getItems()).
Is it possible to create a complex type or a binding that would let me get item list in a single call (e.g. container.getItems())?

If test.xsd looks like this:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="container">
<xs:complexType>
<xs:sequence>
<xs:element name="items">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element name="item"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
and you compile it like this:
xjc -p test test.xsd
this will create bindings that should let you unmarshal your instance into a Container class. That class will contain a getItem() method that returns a java.util.List of items.
-- Ed

Similar Messages

  • XML "container" elements and JAXB

    Hi,
    Does anyone know if there is a way to tell the JAXB compiler not to create classes for certain elements which are just containers for a collection of some other elements. For example, suppose the resultant XML (snippet) is like this:
    <library>
    <books>
      <book .... />
      <book .... />
      <book .... />
    </books>
    </library>What I want to accomplish is tell JAXB compiler to create Library class like this:
    public class Library {
    private Collection books;
    }Currently, what would happen is that JAXB would create Library class like this:
    public class Library {
    private Books books;
    }and then create another class Books like this:
    public class Book {
    private ArrayList book;
    public ArrayList getBook();
    }Obviously, when working with Java code, what I would want is to skip all this nonsense in the middle and just have it the way I showed it in the first example.
    Of course, one solution is not to declare the "books" container element in the schema. However, what I want to know if this is the only solution or there is a way to customize JAXB to get it to produce a class shown in the very first example.
    Thanks,
    Yaakov.

    I believe this question is cross-posted and already answered in http://forums.java.net/jive/forum.jspa?forumID=46

  • JAXB, element order and optional elements

    Hi,
    I am trying to write a program that depends on JAXB and I am encountering a number of problems. The first is that the party from which we get our XML data from is capable of sending the elements in a given element in any order and JAXB is very stringent about order, is there any way to override this behaviour? The next, is if an element, that has children, is marked as optional in the DTD, JAXB will treat it as mandatory which also creates problems for us as some of these type of elements are optional.
    Does anyone know when JAXB ea2 is due?

    To your second topic, this is a known bug in the EA, see
    http://developer.java.sun.com/developer/bugParade/bugs/4497267.html
    To the first topic: If you define the DTD in a way, that the element order is not fixed, then JAXB should accept that. E.g. instead of<!ELEMENT foo (a,b,c)>you could write<!ELEMENT foo ((a|b|c)*)>Of course, this is even looser, as it does not prevent you from sending multiple instances of a, b and c, and the generated code does not contain a getA, getB and getC method, but just a getContent returning a List.

  • Container element in task item text and task description inconsistent

    We use the purchase order release workflow 20000075: Workflow for release of purchase order
    The container element Release indicator (&_WI_Object_Id.ReleaseIndicator&) is used in the PO release effected task TS20000168 in work item text (title) and task desription (body text). 
    When we release the PO a workflow notification is send to the PO creator, the title text shown Release indicator = Z (released) and task body text shown release indicator = Z (same). 
    However, we do a cancel (undo) to the release of the PO, now when we view the same workflow nofication again the task work item text (title) shown Release indicator = Z (released) and task body text shown release indicator = X (blocked) -latest status.   
    In this scenario the title text does not updated with the latest release indicator value, the task body text does. Task work item title text and task body text is inconsistent for the release indicator. When we view the workflow notification at this point is confused with the release indicator Z and X (approved in task tile  and Blocked in task body text).
    Please help how to resolve this issue, any way to make the body text release indicator does not change once the notification is generated??

    This is very weird!!!!!  I will suggest you to check the binding such that the PO Object is binded from Workflow to Task and viceversa.
    Thanks
    Arghadip

  • BPM Container Element and Container in UDF Relation

    Hi,
    I am creating a BPM with container elements. Can I access this container variable value in a Java based mapping User Defined Function. If so, can you please let me know how can I do that.
    Thanks,
    -Padmaja

    Hi Padmaja,
    q1 -Is the target message same in all the cases with different values?
    q2 - Also, after this message(with different content based on the where it is created from) is created is sent out or is it used some where further again in the BPM?
    i am also assuming you are above SP16..
    If the answer is yes to q1 and no to q2, you can achieve this quite easily.....from each of the 3 places(success,failure and deadline)....have a send step each with the source message...in the send step you should have the "ConversationID" field filled with values which distinguishes the place from it is is send....now in the interface determination attach one mapping and in that mapping using a UDF you can access the Conversation ID from mapping variables....and you can manipulate your output message..
    I have made lots of assumptions without knowing your scenario..check it out if it helps...
    Thanks & Regards,
    Renjith

  • JAXB namespace common elements

    Hi,
    I'm generating a parser according to 3 DTDs:
    main.dtd
    devinf.dtd
    metinf.dtd
    I have translated the DTDs in 3 XML schemas with DTD to XML Schema translator (found on w3c) that Translate a Document Type Definition (XML 1.0 DTD) into an XML schema (REC-xmlschema-1-20010502):
    http://puvogel.informatik.med.uni-giessen.de/dtd2xs/
    The main.dtd contains an element Meta defined such as:
    <!-- Meta element type -->
    <!-- Element types in the content MUST have name space declared. -->
    <!--The Meta content would be something such as:
    <Meta>
    <Type xmlns='metinf'>myType</Type>
    <Format xmlns='metinf'>myFormat</Format>
    </Meta>-->
    <!ELEMENT Meta (#PCDATA)>
    AND 2 elements Format and Type!!!!
    Converting to Schema:
    <xs:element name="Meta" type="xs:string" />
    <xs:element name="Format" type="xs:string" />
    <xs:element name="Type" type="xs:string" />
    The metinf DTD defines the elements Type and Format such as after converting in schema we have:
    <xs:element name="Format" type="xs:string" />
    <xs:element name="Type" type="xs:string" />
    The devinf DTD defines also these two elements !!!!
    I tried to modify the main schema to import the devinf and metinf schema. However when I try to compile, I receive the error that the compiler atempts to generates the same interface (Format and Type) from the 3 different schema.
    (compile line is:
    xjc -jar %JAVA_LIBS%\jaxb-xjc.jar -p mypackage devinf.xsl metinf.xsl main.xsl)
    How could I do to obtain a Parser that could read and write the following XML:
    <!-- These Format and Type refer to main.dtd -->
    <Format>formatA</Format>
    <Type>typeA</Type>
    <Meta>
    <!-- These Format and Type refer to metinf.dtd -->
    <Format xmlns="metinf">formatB</Format>
    <Type xmlns="metinf">typeB</Type>
    </Meta>
    <!-- These Format and Type refer to devinf.dtd -->
    <Format xmlns="devinf">formatC</Format>
    <Type xmlns="metinf">typeC</Type>
    Many thanks and sorry for my poor english!

    Sorry to disturb you....
    Sometimes you found you are really stupid.
    The solution for the above problem is to define a custom binding (specifying per example a different package for the different DTDs)
    Sorry again
    Tanguy

  • Container element is not being displayed in email

    Hi Experts,
      I inserted an element from container into email text as below
    The task has been pending in inbox for more than &ins_num& days.
    The value of &ins_num& in container is 9
    In output I get
    The task has been pending in inbox for more than  days.
    Please let me know what is wrong. The binding works fine. No error in workflow.
    Thanks.

    Hi Miak,
    Greetings..:-)
    > I inserted an element from container into email text as below
    > The task has been pending in inbox for more than &ins_num& days.
    > The value of &ins_num& in container is 9
    > In output I get
    > The task has been pending in inbox for more than days.
    > Please let me know what is wrong. The binding works fine. No error in workflow.
    Check on the Following things:->
    1> The Container Element has Initial Value defined, If Yes - it should symbolise in Green Colour.
         If 'Not', then check the WF Log and see whether this Container Element is fetching the Values orr   not.
    2> If the Values are not being Fetched, then the Problem lies with the Binding of these WF Containers.
    Let me know if you are still facing Issues.
    Regards,
    Kanika

  • How to write Header and Footer elements in Write file Adapter

    Hi,
    I have a requirement to write the file.The write file contains header and footer elements ,how we can write these elements. These elements are fixed for all files.these are not come from any input.below is the sample file.
    $begintable
    name,Id,Desg
    ad,12,it
    $endtable

    Hi,
    I have created the XSD for you, and i created a sample SOA Composite which writes the file same like what you want, the below XSD can write a file with one header record, multiple data records and one trailer record.
    <?xml version="1.0" encoding="UTF-8" ?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
    xmlns:tns="http://TargetNamespace.com/WriteFile"
    targetNamespace="http://TargetNamespace.com/WriteFile"
    elementFormDefault="qualified" attributeFormDefault="unqualified"
    nxsd:version="NXSD" nxsd:stream="chars" nxsd:encoding="UTF-8">
    <xsd:element name="Root-Element">
    <xsd:complexType>
    <!--xsd:choice minOccurs="1" maxOccurs="unbounded" nxsd:choiceCondition="terminated" nxsd:terminatedBy=","-->
    <xsd:sequence>
    <xsd:element name="RECORD1">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="header" type="xsd:string"
    nxsd:style="terminated" nxsd:terminatedBy="${eol}"
    nxsd:quotedBy='"'/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="RECORD2" minOccurs="1" maxOccurs="unbounded">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="data1" type="xsd:string"
    nxsd:style="terminated" nxsd:terminatedBy=","
    nxsd:quotedBy='"'/>
    <xsd:element name="data2" type="xsd:string"
    nxsd:style="terminated" nxsd:terminatedBy=","
    nxsd:quotedBy='"'/>
    <xsd:element name="data3" type="xsd:string"
    nxsd:style="terminated" nxsd:terminatedBy="${eol}"
    nxsd:quotedBy='"'/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    <xsd:element name="RECORD4" nxsd:conditionValue="$endtable">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="trailer" type="xsd:string"
    nxsd:style="terminated" nxsd:terminatedBy="${eol}"
    nxsd:quotedBy='"'/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    Hope this helps,
    N

  • XML DB: is it possible to get a row for each element in a container element?

    I have an XML document containing a container element (collection). If I query, using an XPath expression, the contained elements I get a row for each container element with the contained element concatenated. Is it possible to get a row for each contained element?
    I run this simple query:
    select extract(xmltype('<colors><color>Red</color><color>Green</color></colors>')
    , '/colors/color/text()').getstringval() from dual
    And get this result:
    EXTRACT(XMLTYPE('<COLORS><COLOR>RED</COLOR><COLOR>GREEN</COLOR></COLORS>'),'/COL
    RedGreen
    1 row selected.
    What I would like to have is:
    Red
    Green
    2 rows selected.
    Wishful thinking or possible? Many thanks!

    Sure. This is where our XMLSequence() function comes in. It allows you to treat the top-level nodes in a nodeset as if they were rows in a table when combined with the TABLE() operator. Here's an example.
    First, to make the SQL look a little cleaner, I like to define a function like this:
    create or replace function testdoc return xmltype as
    begin
      return xmltype('<colors><color>Red</color><color>Green</color></colors>');
    end;.
    To break out the nodeset of <color> elements as a table, we use the following query:
    select value(list_of_color_elements).extract('*/text()').getStringVal() as color
    from TABLE( XMLSequence( extract(testdoc(),'/colors/color'))) list_of_color_elements.
    Or, using the new-in-9.2 extractValue() operator so we don't have to remember the text() part:
    select extractValue( value(list_of_color_elements), '.') as color
    from TABLE( XMLSequence( extract( testdoc() ,'/colors/color'))) list_of_color_elements.
    Here the TABLE(XMLSequence(...)) combo produces a table of XMLType, with one XMLType object in each row of the table.
    In general, if the XMLType instance were coming from an XMLType table xmltab the query would look like this:
    select extractValue( value(colors), '.') as color
    from xmltab x, /* Important that this table comes earlier in the FROM clause! */
         TABLE( XMLSequence( extract( value(x),'/colors/color'))) colors.
    And if the XMLType were instead in a column of XMLType named doc in a table xmltab, then we would have the syntax:
    select extractValue( value(colors), '.') as color
    from xmltab x, /* Important that this table comes earlier in the FROM clause! */
         TABLE( XMLSequence( extract( x.doc ,'/colors/color'))) colorsOnce you get the hang of it, you'll see that the combination of TABLE(XMLSequence()) to "shred" XML nodes into rows, and XMLAgg() to aggregate fragments of XML across multiple rows back into a single document, is quite powerful.

  • Hiding a container element  from a standard applicaition

    hi,
    i have a requirement to remove the UI elements in a transparent container from a view of a standard webdynpro component HRRCF_C_PREFERENCES_UI. This component is being used as a sub component in a main application.
    The transparent container within has a drop down list and a few buttons.
    So i created a component configuration for the component HRRCF_C_PREFERENCES_UI and changed the property of the UI element in the configuration to invisible. This worked, the container element was invisible in the application. But two other containers next to the UI element that was hidden did not move to the left . No proper alignment.
    Is this the standard behavior of a component configuration? i don't think so.
    Now in my option, the other only possible option is to hide the button by changing the attribute in the WDDOMODIFYVIEW method of the view.
    Could someone please help me how to set the attribute problematically? Is there a different way to meet this requirement?
    Need some help.Thanks.
    Best Regards,
    Sridharan

    Hi,
    Just go to enhancement mode in your webdynpro component and delete that button from UIElement hierarcy.
    If you want your button back, delete the enhancement.
    Regards
    Vishal kapoor

  • Assigning a value to container element in rule defination

    I am using a rule to determine an actual agent. I am using a function module containing actor_tab and ac_conatiner in TABLES parameter. the agent determined is appended to internal table actor_tab. I want this agent to be available in a container element(say: APPROVER) to use it further. I am trying to assingn the agent value to container element using macro  swc_set_element ac_container 'APPROVER' agent-name. But its not working...any other way to assgn this agent to the container element. Bindings from workflow container to rule container are proper.
    Edited by: Rishi Bhatia on Oct 19, 2008 2:46 PM

    i think you cannot modify the container element from Rule.
    the agents of the task determined by the Rule will be stored in some variable of the container automatically (i think it is RuleResult.Agents). you can check this yourself and then bind this element of the task to your APPROVER element.

  • BPM - An empty container element was specified when sending

    Hello Experts,
    My BPM process looks as below:
    Receive -> Loop (execute if the status of IDoc is ERROR(E))--> Mapping ---> End Loop --> Send
    The message is failing in BPM workflow with the log: An empty container element was specified when sending
    Container  for receive and send stepe are different. IP in SXI_CACHE has process code 0.
    Mapping program is defined between the abstarct msg type of receive step and abstract msg type of Send step.
    Th message being processed has initial status as ERROR and after the mapping step is exceuted, it retrieves teh current status i.e SUCCESS. This ends the loop step and while tying to send the messgae to target system, this error occurs.
    Pls advice if I am missing anything.
    Thanks,
    Elizabeth.

    Go to transaction SWWL  , select your integration process instance and delete it
    Create your process with a new name and run the scenario again
    Re: Prob with Integration Process
    regards
    Ninad

  • Error while creating container Element in WF

    Hi,
    I have created a container element with field vbeln, and specified an initial value. Created mail step and activated it.  I have given the mail subject and content  as "value given : &vbeln&".  When I try to test this I couldn't find the container element in " Input Data" tab  of the Test Data and getting the message as "Contnr elem. VBELN  is for read purposes only. No values are assigned to it." 
    Could anyone suggest me to correct this, because I am new to WF.
    Thanks,
    AA

    Hi AA,
    You would probably need to create more than one containers.
    In workflows, we have following types of containers:
    1. Workflow container
    2. Task Container
    3. Event Container
    Now, since you need the element VBELN, try the following:
    1. Create a WF container for VBELN. Make it as both input and output parameter.
    2. Create a container for the Mail Step, again with VBELN field as an input parameter.
    3. There would be a button for binding in the mailstep. Bind the Field VBELN from Work flow container to the Mail Step container.
    Once binding is done, save it and Activate the Workflow.
    Hope this helps.
    Do get back in case of any issues.
    Regards,
    Sonal

  • Show view container elements on click of button in view

    Hi All,
    I have a view ,in that view I have 1 View Container UI Element.In ViewContainer I have a Table.
    I have a button in my view.onclick of that button I want to open a view Container's table.
    Could anyone please suggest me what are all the steps i have to follow for this?
    Regards,
    Karthick

    Hello Karthick,
    1) Create custom controller.
    2) Create attribute with type Visibility in custom controller.
    3) Add custom controller in "required controllers" for embedded view and for container view.
    4) Create attribute with type Visibility in embedded view and container view.
    5) Map visibility attribute from custom controller to container view and from custom controller to embedded view.
    6) in container view in wdDoInit put wdContext.currentContextElement().setVisible(WDVisibility.VISIBLE);
    7) In action handler for button put something like:
         final int ordinal = wdContext.currentContextElement().getVisible().ordinal();
        wdContext.currentContextElement().setVisible(WDVisibility.valueOf(ordinal%2 + 1));
    While clicking on button table would be shown or hidden.
    Best regards, Maksim Rashchynski.

  • The hard drive on my laptop that contained Elements just died.  Can I get a second copy for installation on my new PC?

    The hard drive on my laptop that contained Elements just died.  Can I get a second copy for installation on my new PC?

    The iPhone is not a backup device.
    Restore the iTunes library from the backup that should be kept of your media and other important files.
    Syncing the iPhone to a new library (in this case, it will be a new library unless you have a complete backup of the iTunes folder pre-crash) will result in the media on the device being removed and replaced with content from the new library.
    As for iOS5, we really do not know until Apple officially releases it.

Maybe you are looking for

  • I cannot download one podcast. Tried resubscribing but no luck.

    This only happens with one of my podcasts others update ok. It has the ! symbol by the title in my podcast library. The error message reads> "There was a problem downloading "Best of Today" "http://downloads.bbc.co.uk/podcast/radio4/today/rss.xml" "C

  • Using Oracle Objects In Sqlj Programs

    I had 8.1.5 installed under Mandrake 7.0 and working fine. 8.1.6 installed fine, but dbassist could not create the database at all. I had tried Mandrake 7.1b and Redhat 6.2 with all having the same problem of not being able to create the database. I

  • Newsletter 5-02-04

    Arch Linux Weekly Newsletter *Jason Chu and Ben Mazer*   Opening Welcome to the Arch Linux Newsletter. This attempts to give you an ``at a glance'' look at the world of Arch Linux.   News    1. New GCC, Perl       We've released gcc 3.4.0 to the curr

  • Add, delete and group fields in Application Area of transaction CIC0

    Hi, In the transaction of CIC0, I have the requirements of: - Delete the field "Function" corresponding to the Business Partner 1, all the fields corresponding to Business Partner 2, all the fields corresp. to IBase, and the fields: "Address type" an

  • Motorola Droid - Live Streaming Audio Doesn't Work

    When I try to listen to a live audio stream from http:\\kalx.berkeley.edu, I get a message stating "Cannot download.  The size of the item cannot be determined."  Is there any way I can fix this?