Iterating over XML elements.

10 messages Options
Embed this post
Permalink
uprooter

Iterating over XML elements.

Reply Threaded More More options
Print post
Permalink
Hello.
This may be not ESB related but more BPEL question.
I have a XML complex type that contains a sequence of sub elements.
I managed to run the for-each loop using node count  but I can't find how to assign the iterator to a sub element.
An example of iterating over XML elements would be great.

Thanks.

Kirill Sorokin

Re: Iterating over XML elements.

Reply Threaded More More options
Print post
Permalink
http://lmgtfy.com/?q=bpel+iterating+over+xml+elements

There is an answer in the sixth link from the top. Also, this might be
helpful:
http://wiki.open-esb.java.net/Wiki.jsp?page=Using%20The%20BPEL%20Mapper

Kirill

uprooter wrote:

> Hello.
> This may be not ESB related but more BPEL question.
> I have a XML complex type that contains a sequence of sub elements.
> I managed to run the for-each loop using node count  but I can't find how to
> assign the iterator to a sub element.
> An example of iterating over XML elements would be great.
>
> Thanks.
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

uprooter

Re: Iterating over XML elements.

Reply Threaded More More options
Print post
Permalink
Thanks.
It cleared my eyes all thought wasn't clear enough.
I'll write the steps below for the next to come across this.
1. Take your container element, the one which contains the sequences.
2. Add predicate for it (right click).
3. In the predicate editor: connect the for-each counter variable on the left to the "predicate" on the right.
Very easy, not well documented.
Thanks.


Kirill Sorokin wrote:
http://lmgtfy.com/?q=bpel+iterating+over+xml+elements

There is an answer in the sixth link from the top. Also, this might be
helpful:
http://wiki.open-esb.java.net/Wiki.jsp?page=Using%20The%20BPEL%20Mapper

Kirill

uprooter wrote:
> Hello.
> This may be not ESB related but more BPEL question.
> I have a XML complex type that contains a sequence of sub elements.
> I managed to run the for-each loop using node count  but I can't find how to
> assign the iterator to a sub element.
> An example of iterating over XML elements would be great.
>
> Thanks.
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@open-esb.dev.java.net
For additional commands, e-mail: users-help@open-esb.dev.java.net
Kirill Sorokin

Re: Iterating over XML elements.

Reply Threaded More More options
Print post
Permalink
> Very easy, not well documented.

Yeah. Known pain, working on it.. Sorry. :(

Kir

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

fozon

Re: Iterating over XML elements.

Reply Threaded More More options
Print post
Permalink
Hello,

I have a question. I am dealing with a xsd that looks like the following one:



The code is the following one:

    <xsd:complexType name="crazyType">
        <xsd:sequence maxOccurs="unbounded">
            <xsd:element name="rootElement">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="realChild" type="tns:normalType"/>
                    </xsd:sequence>
                    <xsd:attribute name="rootElementAttribute" type="xsd:string"/>
                </xsd:complexType>
            </xsd:element>
            <xsd:sequence maxOccurs="unbounded">
                <xsd:element name="child1Element" type="xsd:string"/>
                <xsd:element name="child2Element" type="xsd:string"/>
                <xsd:element name="child3Element" type="xsd:string"/>
            </xsd:sequence>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="normalType">
        <xsd:sequence>
            <xsd:element name="normalChild1" type="xsd:string"/>
            <xsd:element name="normalChild2" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>


Here you can see that the sequence of SEQ={{child1element,child2element,child3element}*} is an unbounded sequence. This sequence is contained with another sequence in the crazyElement. outerSEQ={{rootElement,SEQ}*}

The problem now is how to read every node relating every "child?Element" with its corresponding "rootElement".

You can obtain the count of the "rootElement" and iterate over them. You can also obtain the count of the "child1element" and iterate over them. This is a global count refering to the whole file, but you can not access to the "child1Element" elements related to one specific "rootElement".

I think this could be solved changing the xsd to the following one:



whose code is the following one.
    <xsd:complexType name="reliableType">
        <xsd:sequence maxOccurs="unbounded">
            <xsd:element name="rootElement">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="realChild" type="tns:normalType"/>
                        <xsd:element name="repeatedType" type="tns:containerType" maxOccurs="unbounded"/>
                    </xsd:sequence>
                    <xsd:attribute name="rootElementAttribute" type="xsd:string"/>
                </xsd:complexType>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="containerType">
        <xsd:sequence>
            <xsd:element name="child1Element" type="xsd:string"></xsd:element>
            <xsd:element name="child2Element" type="xsd:string"/>
            <xsd:element name="child3Element" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="normalType">
        <xsd:sequence>
            <xsd:element name="normalChild1" type="xsd:string"/>
            <xsd:element name="normalChild2" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>


I provide you an example that shows the difficulty to parser one file with the first format and write it in a file with the second one. Just run the attachment and you will see that if the number of "child?Element" under every "rootElement" is not the same, there is a difficulty to fulfill the transformation.

I also tried to do the xsl transformation with the file included in the NetBeans project, but xsl is not my best and I was unsuccessful.



Thanks you for reading such a long mail,
Gabriel.
fozon

Re: Iterating over XML elements.

Reply Threaded More More options
Print post
Permalink
And here is the attachment. parseXML.zip

fozon wrote:
Hello,

I have a question. I am dealing with a xsd that looks like the following one:



The code is the following one:

    <xsd:complexType name="crazyType">
        <xsd:sequence maxOccurs="unbounded">
            <xsd:element name="rootElement">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="realChild" type="tns:normalType"/>
                    </xsd:sequence>
                    <xsd:attribute name="rootElementAttribute" type="xsd:string"/>
                </xsd:complexType>
            </xsd:element>
            <xsd:sequence maxOccurs="unbounded">
                <xsd:element name="child1Element" type="xsd:string"/>
                <xsd:element name="child2Element" type="xsd:string"/>
                <xsd:element name="child3Element" type="xsd:string"/>
            </xsd:sequence>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="normalType">
        <xsd:sequence>
            <xsd:element name="normalChild1" type="xsd:string"/>
            <xsd:element name="normalChild2" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>


Here you can see that the sequence of SEQ={{child1element,child2element,child3element}*} is an unbounded sequence. This sequence is contained with another sequence in the crazyElement. outerSEQ={{rootElement,SEQ}*}

The problem now is how to read every node relating every "child?Element" with its corresponding "rootElement".

You can obtain the count of the "rootElement" and iterate over them. You can also obtain the count of the "child1element" and iterate over them. This is a global count refering to the whole file, but you can not access to the "child1Element" elements related to one specific "rootElement".

I think this could be solved changing the xsd to the following one:



whose code is the following one.
    <xsd:complexType name="reliableType">
        <xsd:sequence maxOccurs="unbounded">
            <xsd:element name="rootElement">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="realChild" type="tns:normalType"/>
                        <xsd:element name="repeatedType" type="tns:containerType" maxOccurs="unbounded"/>
                    </xsd:sequence>
                    <xsd:attribute name="rootElementAttribute" type="xsd:string"/>
                </xsd:complexType>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="containerType">
        <xsd:sequence>
            <xsd:element name="child1Element" type="xsd:string"></xsd:element>
            <xsd:element name="child2Element" type="xsd:string"/>
            <xsd:element name="child3Element" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="normalType">
        <xsd:sequence>
            <xsd:element name="normalChild1" type="xsd:string"/>
            <xsd:element name="normalChild2" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>


I provide you an example that shows the difficulty to parser one file with the first format and write it in a file with the second one. Just run the attachment and you will see that if the number of "child?Element" under every "rootElement" is not the same, there is a difficulty to fulfill the transformation.

I also tried to do the xsl transformation with the file included in the NetBeans project, but xsl is not my best and I was unsuccessful.



Thanks you for reading such a long mail,
Gabriel.
fozon

Re: Iterating over XML elements.

Reply Threaded More More options
Print post
Permalink
Nobody can help me? I think it should be a way to iterate sequentially over all the nodes in the file. BPEL SE has to be able to perform this operation, but I can't figure out how.

I would appreciate your help.

Thanks,
Gabriel.


fozon wrote:
Hello,

I have a question. I am dealing with a xsd that looks like the following one:



The code is the following one:

    <xsd:complexType name="crazyType">
        <xsd:sequence maxOccurs="unbounded">
            <xsd:element name="rootElement">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="realChild" type="tns:normalType"/>
                    </xsd:sequence>
                    <xsd:attribute name="rootElementAttribute" type="xsd:string"/>
                </xsd:complexType>
            </xsd:element>
            <xsd:sequence maxOccurs="unbounded">
                <xsd:element name="child1Element" type="xsd:string"/>
                <xsd:element name="child2Element" type="xsd:string"/>
                <xsd:element name="child3Element" type="xsd:string"/>
            </xsd:sequence>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="normalType">
        <xsd:sequence>
            <xsd:element name="normalChild1" type="xsd:string"/>
            <xsd:element name="normalChild2" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>


Here you can see that the sequence of SEQ={{child1element,child2element,child3element}*} is an unbounded sequence. This sequence is contained with another sequence in the crazyElement. outerSEQ={{rootElement,SEQ}*}

The problem now is how to read every node relating every "child?Element" with its corresponding "rootElement".

You can obtain the count of the "rootElement" and iterate over them. You can also obtain the count of the "child1element" and iterate over them. This is a global count refering to the whole file, but you can not access to the "child1Element" elements related to one specific "rootElement".

I think this could be solved changing the xsd to the following one:



whose code is the following one.
    <xsd:complexType name="reliableType">
        <xsd:sequence maxOccurs="unbounded">
            <xsd:element name="rootElement">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="realChild" type="tns:normalType"/>
                        <xsd:element name="repeatedType" type="tns:containerType" maxOccurs="unbounded"/>
                    </xsd:sequence>
                    <xsd:attribute name="rootElementAttribute" type="xsd:string"/>
                </xsd:complexType>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="containerType">
        <xsd:sequence>
            <xsd:element name="child1Element" type="xsd:string"></xsd:element>
            <xsd:element name="child2Element" type="xsd:string"/>
            <xsd:element name="child3Element" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="normalType">
        <xsd:sequence>
            <xsd:element name="normalChild1" type="xsd:string"/>
            <xsd:element name="normalChild2" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>


I provide you an example that shows the difficulty to parser one file with the first format and write it in a file with the second one. Just run the attachment and you will see that if the number of "child?Element" under every "rootElement" is not the same, there is a difficulty to fulfill the transformation.

I also tried to do the xsl transformation with the file included in the NetBeans project, but xsl is not my best and I was unsuccessful.



Thanks you for reading such a long mail,
Gabriel.
Andy Knight

Re: Iterating over XML elements.

Reply Threaded More More options
Print post
Permalink
Are you familiar with predicates in BPEL?

You have, essentially, a 2-dimensional array. Predicates can be nested.

         Andy Knight
Principal Engineer,
Sun Microsystems, Inc.
Java House, Guillemont Park, Minley Road,
Camberley, Surrey GU17 9QG United Kingdom
Home office: +44 1494 462438
Mobile: +44 7775 583415
Skype: aprknight
Email: [hidden email]
Blog: http://blogs.sun.com/andky

On 9 Nov 2009, at 09:46, fozon wrote:

>
> Nobody can help me? I think it should be a way to iterate  
> sequentially over
> all the nodes in the file. BPEL SE has to be able to perform this  
> operation,
> but I can't figure out how.
>
> I would appreciate your help.
>
> Thanks,
> Gabriel.
>
>
>
> fozon wrote:
>>
>> Hello,
>>
>> I have a question. I am dealing with a xsd that looks like the  
>> following
>> one:
>>
>> http://n2.nabble.com/file/n3945691/crazyXSD.png
>>
>> The code is the following one:
>>
>>
>>    <xsd:complexType name="crazyType">
>>        <xsd:sequence maxOccurs="unbounded">
>>            <xsd:element name="rootElement">
>>                <xsd:complexType>
>>                    <xsd:sequence>
>>                        <xsd:element name="realChild"
>> type="tns:normalType"/>
>>                    </xsd:sequence>
>>                    <xsd:attribute name="rootElementAttribute"
>> type="xsd:string"/>
>>                </xsd:complexType>
>>            </xsd:element>
>>            <xsd:sequence maxOccurs="unbounded">
>>                <xsd:element name="child1Element" type="xsd:string"/>
>>                <xsd:element name="child2Element" type="xsd:string"/>
>>                <xsd:element name="child3Element" type="xsd:string"/>
>>            </xsd:sequence>
>>        </xsd:sequence>
>>    </xsd:complexType>
>>    <xsd:complexType name="normalType">
>>        <xsd:sequence>
>>            <xsd:element name="normalChild1" type="xsd:string"/>
>>            <xsd:element name="normalChild2" type="xsd:string"/>
>>        </xsd:sequence>
>>    </xsd:complexType>
>>
>>
>> Here you can see that the sequence of
>> SEQ={{child1element,child2element,child3element}*} is an unbounded
>> sequence. This sequence is contained with another sequence in the
>> crazyElement. outerSEQ={{rootElement,SEQ}*}
>>
>> The problem now is how to read every node relating every "child?
>> Element"
>> with its corresponding "rootElement".
>>
>> You can obtain the count of the "rootElement" and iterate over  
>> them. You
>> can also obtain the count of the "child1element" and iterate over  
>> them.
>> This is a global count refering to the whole file, but you can not  
>> access
>> to the "child1Element" elements related to one specific  
>> "rootElement".
>>
>> I think this could be solved changing the xsd to the following one:
>>
>> http://n2.nabble.com/file/n3945691/reliableXSD.png
>>
>> whose code is the following one.
>>
>>    <xsd:complexType name="reliableType">
>>        <xsd:sequence maxOccurs="unbounded">
>>            <xsd:element name="rootElement">
>>                <xsd:complexType>
>>                    <xsd:sequence>
>>                        <xsd:element name="realChild"
>> type="tns:normalType"/>
>>                        <xsd:element name="repeatedType"
>> type="tns:containerType" maxOccurs="unbounded"/>
>>                    </xsd:sequence>
>>                    <xsd:attribute name="rootElementAttribute"
>> type="xsd:string"/>
>>                </xsd:complexType>
>>            </xsd:element>
>>        </xsd:sequence>
>>    </xsd:complexType>
>>    <xsd:complexType name="containerType">
>>        <xsd:sequence>
>>            <xsd:element name="child1Element"
>> type="xsd:string"></xsd:element>
>>            <xsd:element name="child2Element" type="xsd:string"/>
>>            <xsd:element name="child3Element" type="xsd:string"/>
>>        </xsd:sequence>
>>    </xsd:complexType>
>>    <xsd:complexType name="normalType">
>>        <xsd:sequence>
>>            <xsd:element name="normalChild1" type="xsd:string"/>
>>            <xsd:element name="normalChild2" type="xsd:string"/>
>>        </xsd:sequence>
>>    </xsd:complexType>
>>
>>
>> I provide you an example that shows the difficulty to parser one  
>> file with
>> the first format and write it in a file with the second one. Just  
>> run the
>> attachment and you will see that if the number of "child?Element"  
>> under
>> every "rootElement" is not the same, there is a difficulty to  
>> fulfill the
>> transformation.
>>
>> I also tried to do the xsl transformation with the file included in  
>> the
>> NetBeans project, but xsl is not my best and I was unsuccessful.
>>
>>
>>
>> Thanks you for reading such a long mail,
>> Gabriel.
>>
>
> --
> View this message in context: http://n2.nabble.com/Iterating-over-XML-elements-tp2444824p3972077.html
> Sent from the OpenESB Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

fozon

Re: Iterating over XML elements.

Reply Threaded More More options
Print post
Permalink
Thanks for your reply,

I tried to do a nested predicate, but if you pay attention to the first xsd I posted, the elements are not nested. What you say should work in the second case, but I cant get it working in the first one. Since the childEements are not child of rootElement but contained in a scope that is sibling of rootElement. So I cannot access to the childElemens in the way rootElement[i].childElement[j].

It has to be done in some other way.

I hope my problem is now better explained.

Thanks,
Gabriel.

Andy Knight wrote:
Are you familiar with predicates in BPEL?

You have, essentially, a 2-dimensional array. Predicates can be nested.

         Andy Knight
Principal Engineer,
Sun Microsystems, Inc.
Java House, Guillemont Park, Minley Road,
Camberley, Surrey GU17 9QG United Kingdom
Home office: +44 1494 462438
Mobile: +44 7775 583415
Skype: aprknight
Email: Andy.Knight@Sun.COM
Blog: http://blogs.sun.com/andky
fozon

Re: Iterating over XML elements.

Reply Threaded More More options
Print post
Permalink
If someone wants to help me but doesn't understand the question, please, don't hesitate to ask.


fozon wrote:
Thanks for your reply,

I tried to do a nested predicate, but if you pay attention to the first xsd I posted, the elements are not nested. What you say should work in the second case, but I cant get it working in the first one. Since the childEements are not child of rootElement but contained in a scope that is sibling of rootElement. So I cannot access to the childElemens in the way rootElement[i].childElement[j].

It has to be done in some other way.

I hope my problem is now better explained.

Thanks,
Gabriel.

Andy Knight wrote:
Are you familiar with predicates in BPEL?

You have, essentially, a 2-dimensional array. Predicates can be nested.

         Andy Knight
Principal Engineer,
Sun Microsystems, Inc.
Java House, Guillemont Park, Minley Road,
Camberley, Surrey GU17 9QG United Kingdom
Home office: +44 1494 462438
Mobile: +44 7775 583415
Skype: aprknight
Email: Andy.Knight@Sun.COM
Blog: http://blogs.sun.com/andky