This project has moved. For the latest updates, please go here.

SetContextPropertyFromXPathResult with Namespace For Repeating Elements

Mar 16, 2015 at 9:09 PM
Hi johann,
i have been using BRE Pipeline framework in pipeline validate stage for message manipulation i have used custom meta instructions for manipulating and processing other instructions.
i need to promote a repeating element in my schema but unfortunately i will not be able to change the schema standard .

i have tried to promote element value to message context using "SetContextPropertyFromXPathResult" vocabulary definition using various XPath combinations
with [local-name()='Query' and namespace='http://test.com'] notation and using namespace alias "//ns5:Query[1]/ns3:QueryText[1]" and without namespace "//Query/QueryText" with out any success.

i went through the source and observed that XPath reader has not been used with namespace manager which will help with aliasing XPath.

i'm not sure if i'm missing something can you provide a sample if current framework can handle XPath with namespace to promote elements from message body to message context.

if this feature is not available i'm planning on editing the framework locally for this purpose wanted to make sure that this is not a feature to be released soon.

Thanks in advance.
  • kumar
Coordinator
Mar 16, 2015 at 9:18 PM
Hi Kumar,

I'll have a look for you shortly and get back to you as to whether it's possible or whether I can make a fix easily.

If you do decide that you will make the change then I'm happy to apply that to the framework as well with some unit test additions.

Cheers
Johann



Mar 19, 2015 at 2:53 PM
Johann,
on more testing it seems with current framework implementation i was able to query xml with out any namespace and xpath

here is the test xml:
             <books>
                        <book>
                            <title>title1</title>
                            <author>author1</author>
                        </book>
                        <book>
                            <title>title2</title>
                            <author>author2</author>
                        </book>
                  </books>
Test Xpath: //book[2]/title
Result: works
does not work with namespace on xml

i have modified BRE Pipeline Framework sample instructions and helper to handle namespace with XPathReader which seems to work fine with namespace but it not working with fully qualified element form XML with namespace alias.
here is the test xml:
                   <books xmlns="http://books.com">
                        <book xmlns="http://books.com/book">
                            <title>title1</title>
                            <author>author1</author>
                        </book>
                        <book xmlns="http://books.com/book">
                            <title>title2</title>
                            <author>author2</author>
                        </book>
                  </books>
Namespace a = http://books.com
Namespace b = http://books.com/book
Test Xpath: //b:book[2]/b:title
Result: works fine
does not work when tested using fully qualified element form xml with namespace alias.

here is the test xml:
              <ns0:books xmlns:ns0="http://books.com" 
                                 xmlns:ns1="http://books.com/book">
                        <ns1:book>
                            <title>title1</title>
                            <author>author1</author>
                        </ns1:book>
                        <ns1:book>
                            <title>title2</title>
                            <author>author2</author>
                        </ns1:book>
                  </ns0:books>
Namespace a = http://books.com
Namespace b = http://books.com/book
Test Xpath: //b:book[2]/b:title
Result: does not work.

i ended up writing a custom Meta Instruction which seems to be working fine for my case but a better solution would be welcome.

Thanks
@kumar
Coordinator
Mar 19, 2015 at 2:57 PM
Great, thanks so much for taking the time out to investigate this Kumar. It's been a rough week for me so I haven't had time yet and your work is very helpful. I'll definitely take a closer look at this because I am planning a minor version release shortly.

Cheers
Johann



Jun 16, 2016 at 3:00 PM
Hi Johann,
I'm currently trying to achieve the same goal as Kumar, are there any updates or may I have to write a custom Meta Instruction?
Thanks.