Difference between revisions of "Custom Field Type: Special - Advanced Data Table"

From SmartWiki
Jump to: navigation, search
Line 58: Line 58:
 
:<font size=3>'''@xml.'''''field name.parentnodename.nodename'''''.attribute('''''attributename''''')@</font>
 
:<font size=3>'''@xml.'''''field name.parentnodename.nodename'''''.attribute('''''attributename''''')@</font>
 
:* There may not be a parent node, or there may be multiple parent nodes, depending on how the XML is formatted.
 
:* There may not be a parent node, or there may be multiple parent nodes, depending on how the XML is formatted.
 +
 +
 +
Counting nodes:
 +
:<font size=3>'''@xml.'''''field name.parentnodename.nodename'''''.nodecount</font>
  
 
   
 
   

Revision as of 08:59, 21 April 2011

The XML Field Type is used to store a block of XML.

The XML stored in this field can be:

  • Copied and Pasted from a source file.
  • Stored into the field from a workflow process using the SmartSimple Integration Server.
  • Other Web Service types processes.

Example

Here is an example of XML field called mypasta which stores a recipe (Note that although this stores only one, multiple recipes could be stored in the same block of XML):

<?xml version="1.0" encoding="UTF-8"?>
<recipe>
   <title>Beef Parmesan with Garlic Angel Hair Pasta</title>
   <Author>
      <Firstname>Wendy</Firstname>
      <Lastname>Houston</Lastname>
      <Address>
         <Street>148 Peter Street</Street>
         <postalcode>L7Y 2P5</postalcode>
      </Address>
   </Author>
   <ingredients>
      <ingredient amount="1.5" unit="pound">Beef cube</ingredient>
      <ingredient amount="2" unit="kg">Italian Pasta</ingredient>
   </ingredients>
   <preparation>
      <step order='1'>
         <description>Preheat oven to 350 degrees F (175 degrees C).</description>
      </step>
      <step order='2'>
         <description>Mix all ingredients.</description>
      </step
      <step order='3'>
         <description>Put everything into oven.</description>
      </step>
         <description>Done.</description>
      </step>
     <step order='5'>
        <description>Find a phone number of the closest take out restaurant.</description> 
     </step>
   </preparation>
   <comment> Make the meat ahead of time, and refrigerate over night, the acid in the  tomato sauce will tenderize the meat even more. 
            If you do this, save the  mozzarella till the last minute.
   </comment>
   <nutrition calories="1167" fat="23" carbohydrates="45" protein="32"/>
</recipe>


Variables

Access to the data within the XML field uses standard SmartSimple variable references.

@xml.field name.parentnodename.nodename.nodevalue
@xml.#fieldid#.parentnodename.nodename.nodevalue
@xml.field name.parentnodename.nodename.attribute(attributename)@
  • There may not be a parent node, or there may be multiple parent nodes, depending on how the XML is formatted.


Counting nodes:

@xml.field name.parentnodename.nodename.nodecount


For child records:

@xml.fieldname.nodename[# ~nodevalue~ ~attributes(attribute name)~ #]@
@xml.fieldname.nodename[# ~childnodename.nodevalue~ ~childnodename.attributes(attribute name)~ #]@


  • Important: XML node names are case sensitive.

Variable Examples

Created By @xml.mypasta.Author.Firstname.nodevalue@ @xml.mypasta.Author.Lastname.nodevalue@
  • Result: Created By Wendy Houston


@xml.mypasta.Author.Address.Street.nodevalue@ @xml.mypasta.Author.Address.postalcode.nodevalue@
  • Result: 148 Peter Street L7Y 2P5


@xml.mypasta.title.nodevalue@  
@xml.mypasta.comment.nodevalue@ 
Calories=@xml.mypasta.nutrition.attributes(calories)@
  • Result:

Beef Parmesan with Garlic Angel Hair Pasta
Make the meat ahead of time, and refrigerate over night, the acid in the tomato sauce will tenderize the meat even more. If you do this, save the mozzarella till the last minute.
Calories=1167


Ingredients
Name - amount - unit
@xml.mypasta.ingredients.ingredient[#~nodevalue~ - ~attributes(amount)~ - ~attributes(unit)~#]@
  • Result:

Ingredients
Name - amount - unit
Beef cube - 1.5 - pound
Italian Pasta - 2 - kg


Steps
Order Description
@xml.mypasta.preparation.step[#~attributes(order)~ ~description.nodevalue~#]@
  • Result:

Steps
Order Description
1 Preheat oven to 350 degrees F (175 degrees C).
2 Mix all ingredients.
3 Put everything into oven.
4 Done.
5 Find a phone number of the closest take out restaurant.


To format as currency:

@xml.Budget.source.category-total.currency(cash.nodevalue)@