7 Replies Latest reply on Oct 2, 2012 9:21 AM by Gary Brown

    BaseModel and QName attributes

    Gary Brown Master



      I have a ComponentImplementationModel that has an attribute which is a QName. Currently this gets returned as a string, but then I only get the namespace prefix and local part, whereas I would actually like to have the qname (i.e. namespace and local part).


      There does not seem to be an obvious way to resolve the namespace on the model - can someone point me in the right direction? just wondering whether there should be a 'getModelAttributeAsQName' method on the BaseModel?


      Thanks in advance.




        • 1. Re: BaseModel and QName attributes
          David Ward Master

          There isn't a direct way on the interface right now, however:

          1. I added a jira to cover this: https://issues.jboss.org/browse/SWITCHYARD-1058
          2. You can, for now:


          // pseudo

          public class MyModel extends BaseModel {

              public QName getFoo() {

                  String foo = getModelAttribute("foo");

                  if (foo != null && foo.indexOf(':') != -1) {

                      String [] split = foo.split(":", 2);

                     Map<String,String> map = getModelConfiguration().getPrefixNamespaceMap();

                      String ns = map.get(split[0]);

                      String localName = split[1];

                      return new QName(ns, localName);




          1 of 1 people found this helpful
          • 2. Re: BaseModel and QName attributes
            Gary Brown Master

            Thanks David, I'll give it a go.

            • 3. Re: BaseModel and QName attributes
              Gary Brown Master

              Unfortunately didn't work. I have the following switchyard.xml:



              <?xml version="1.0" encoding="UTF-8"?>
              <switchyard xmlns="urn:switchyard-config:switchyard:1.0"
                   <sca:composite name="loanservice" targetNamespace="urn:bpel:test:1.0">
                      <sca:service name="loanService" promote="loanService">
                       <sca:component name="loanService">
                           <bpel:implementation.bpel process="ls:loanApprovalProcess" />
                           <sca:service name="loanService">
                               <sca:interface.wsdl interface="loanServicePT.wsdl#wsdl.porttype(loanServicePT)"/>
                           <sca:reference name="riskAssessor" >
                               <sca:interface.wsdl interface="riskAssessmentPT.wsdl#wsdl.porttype(riskAssessmentPT)"/>
                       <sca:component name="riskAssessor" >
                           <bpel:implementation.bpel process="ra:riskAssessmentProcess" />
                           <sca:service name="riskAssessor">
                               <sca:interface.wsdl interface="riskAssessmentPT.wsdl#wsdl.porttype(riskAssessmentPT)"/>


              When I attempt to retrieve the QName for the first "bpel:implementation" model element, the namespace/prefix map contains:


              map={ns0=http://www.w3.org/2000/xmlns/, ns1=http://docs.oasis-open.org/ns/opencsa/sca/200903}




              • 4. Re: BaseModel and QName attributes
                David Ward Master

                Okay, I'll squeeze something into 0.6.0-SNAPSHOT for you later today.

                • 5. Re: BaseModel and QName attributes
                  David Ward Master

                  Sorry; it's gonna hafta be tomorrow.

                  • 6. Re: BaseModel and QName attributes
                    David Ward Master



                    I finally submitted a pull request that fixes https://issues.jboss.org/browse/SWITCHYARD-1058 for you.


                    You can now call getModelAttributeAsQName(String):QName or getModelAttributeAsQName(QName):QName.  You can also set model attibutes as qnames.


                    I tested it with your XML, and I get the proper qnames out per your examples, testing the prefix, namespace and local parts are all good:


                    pfx: ls

                    ns: http://example.com/loan-approval/loanService/

                    lp: loanApprovalProcess



                    pfx: ra

                    ns: http://example.com/loan-approval/riskAssessment/

                    lp: riskAssessmentProcess


                    So once this gets processed, you should be good to go.  Thanks for your patience!