How to for-each through XML results [Delivery Server] [Dynament]

45 views
Skip to first unread message

Walter

unread,
Jan 3, 2017, 7:34:39 PM1/3/17
to RedDot CMS Users
Hi All,

I'm trying to do the following with Delivery Server Dynaments:

  1. Retrieve data from SQL Server [done]
  2. Loop through the resulting nodes [at-my-wit's-end] 
How do you loop through the nodes with the for-each dynament?  Here is what I have so far:

  1. <rde-dm:rdb mode='statement' alias='externalDB' operation='getAttributeValues' rde-id='10' row="item" tag="attributeValues" cachingtime="60">  
  2.      <rde-rd:param type="string">EN</rde-rd:param>  
  3.      <rde-rd:param type="string">cb_friction</rde-rd:param>                            
  4. </rde-dm:rdb>  
  5.   
  6. <rde-dm:attribute mode="for-each" source="rde-id" attribute="attributeValues.item" type="node">  
  7.      <p>Test</p>  
  8. </rde-dm:attribute>  

I would expect "Test" to be outputted for as many "item" nodes in the result...  But I must not be accessing it correctly.

Below is the result of the prepared statement when I test it in Delivery Server:

  1. <debug xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:rdf="http://www.w3.org/TR/REC-rdf-syntax/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  
  2.   
  3.   
  4. <attributeValues chunk="1" chunksize="1000" description="Connector for externalDB" hits="99" lastchunk="1" maxchunk-ca="1" maxhits="0">  
  5.       <item>  
  6.         <Key>bore</Key>  
  7.         <Value>0.125 in</Value>  
  8.       </item>  
  9.       <item>  
  10.         <Key>bore</Key>  
  11.         <Value>0.187 in</Value>  
  12.       </item>  
  13.       <item>  
  14.         <Key>bore</Key>  
  15.         <Value>0.25 in</Value>  
  16.       </item>  
  17.       <item>  
  18.         <Key>bore</Key>  
  19.         <Value>0.3125 in</Value>  
  20.       </item>  
  21.       <item>  
  22.         <Key>bore</Key>  
  23.         <Value>0.375 in</Value>  
  24.       </item>  
  25.     </attributeValues>  
  26. </debug>  
I would be grateful for any help.  Thanks!

Walter


Hilmar Bunjes

unread,
Jan 4, 2017, 10:13:56 AM1/4/17
to RedDot CMS Users
Walter,
in the for-each attribute you are missing the rde-id "10", so you say rde-id but there is no reference to which one exactly. The attribute should be something like "rde-id:10:attributeValues.item".

If possible I would use xml/xslt or xpath to access the values.

Best,
Hilmar
Reply all
Reply to author
Forward
0 new messages