Topic
  • 3 replies
  • Latest Post - ‏2013-06-27T07:29:23Z by HermannSW
rdp87
rdp87
59 Posts

Pinned topic Iteration in SOMA requests

‏2013-06-26T12:10:25Z |

Hi All,

Is it possible to use xsl:for-each for SOMA requests in xslt.

Thanks....

  • HermannSW
    HermannSW
    6019 Posts

    Re: Iteration in SOMA requests

    ‏2013-06-26T14:52:08Z  

    http://www.w3.org/TR/xslt#for-each is an XSLT statement, SOMA requests are XML data
    (see https://www.ibm.com/developerworks/community/blogs/HermannSW/entry/xml_management_sample_requests36).

    You can access the XML management interface from within a stylesheet:
    https://www.ibm.com/developerworks/community/blogs/HermannSW/entry/accessing_xml_management_interface_from_within_a_stylesheet38

    Then you can iterate through the reponse by xsl:for-each.


    Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>

     

  • rdp87
    rdp87
    59 Posts

    Re: Iteration in SOMA requests

    ‏2013-06-27T07:20:02Z  
    • HermannSW
    • ‏2013-06-26T14:52:08Z

    http://www.w3.org/TR/xslt#for-each is an XSLT statement, SOMA requests are XML data
    (see https://www.ibm.com/developerworks/community/blogs/HermannSW/entry/xml_management_sample_requests36).

    You can access the XML management interface from within a stylesheet:
    https://www.ibm.com/developerworks/community/blogs/HermannSW/entry/accessing_xml_management_interface_from_within_a_stylesheet38

    Then you can iterate through the reponse by xsl:for-each.


    Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>

     

    Hi Hermann,

    Thanks for the info.

    My scenario is like I have put few domains name in a xml file with structure as follow:

    <Domain><Name>domainA</Name><Name>domainB</Name></Domain>

    Now I put my soma request in xsl and want to iterate through each domain name using xsl:for-each to perform certain operation but iteration is happening twice for domainA and not going to domainB. Not sure if I am missing out something here.

    Thanks...

  • HermannSW
    HermannSW
    6019 Posts

    Re: Iteration in SOMA requests

    ‏2013-06-27T07:29:23Z  
    • rdp87
    • ‏2013-06-27T07:20:02Z

    Hi Hermann,

    Thanks for the info.

    My scenario is like I have put few domains name in a xml file with structure as follow:

    <Domain><Name>domainA</Name><Name>domainB</Name></Domain>

    Now I put my soma request in xsl and want to iterate through each domain name using xsl:for-each to perform certain operation but iteration is happening twice for domainA and not going to domainB. Not sure if I am missing out something here.

    Thanks...

    This should do what you want

    ...
    <xsl:for-each select="document('yourFile.xml')/Domain/Name">
      <!--

        here "string(.)" contauns "domainA", "domainB", ...
      -->
      <xsl:message><xsl:value-of select="."/></xsl:message>
      <!--
        generate SOMA request with "string(.)" here and execute
      -->
    </xsl:for-each>
    ...


    Hermann<myXsltBlog/> <myXsltTweets/> <myCE/>