×
Menu
Index

Absolute paths

 

When we use absolute paths to address elements in XML documents, the context (where are we in the XML document?) is not of any importance. Elements are addressed with a full path, so coming from the rootelement. In our previous example the information from the Insured node has to be copied to the Driver node.
 
<CustomerDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://SoftRules.com/CustomerDocument.xsd">
     <CustomerWrapper>
          <Insured>
               <ID>69866</ID>
               <Firstname>John</Firstname>
               <SirName>Tapscott</SirName>
               <Street>Steele Street</Street>
               <HouseNumber>1362</HouseNumber>
               <Zipcode>60187</Zipcode>
               <Town>Wheaton</Town>
               <EmailAddress>jtapscott@softrules.com</EmailAddress>
          </Insured>
     </CustomerWrapper>
     <Contract>
          <Policy>
               <MotorVehicle>
                    <Driver>
                         <Firstname/>
                         <SirName/>
                         <Street/>
                         <HouseNumber/>
                         <Zipcode/>
                         <Town/>
                         <EmailAddress/>
                    </Driver>
               </MotorVehicle>
          </Policy>
     </Contract>
</CustomerDocument>
 
Using absolute paths, it will look like this:
 
CustomerDocument/Contract/Policy/MotorVehicle/Driver/Firstname = CustomerDocument/CustomerWrapper/Insured/Firstname
CustomerDocument/Contract/Policy/MotorVehicle/Driver/Sirname = CustomerDocument/CustomerWrapper/Insured/Sirname
etc.
 
In SoftRules® we would use Assignments for this job.
 
 
 
This solution is, however functional, not very practical. Suppose we would have to do the same in the second Contract node, than we would have to copy all Tools instead of reuse them. So, it's better to use relative paths, see here.