×
Menu
Index

Relative paths

 

If we use relative paths to address an element in an XML document, the current location (our context) is very important. A relative path start its navigation from this location. In this case we have to copy a number of elements from Insured to Driver.
 
<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>
 
Our Context is  CustomerDocument/Contract (blue highlighted).
 
This would be the syntax using relative addressing:
 
./Policy/MotorVehicle/Driver/Firstname = ../CustomerWrapper/Insured/Firstname
./Policy/MotorVehicle/Driver/Sirname = ../CustomerWrapper/Insured/Sirname
etc.
 
In an Assignment:
 
 
Attention!
Because we change the Alt. path of the Assignment, the total Assignments context is changed. So our relative path used in value should start from the new context (CustomerDocument/Contract/Policy/MotorVehicle/Driver) instead of the old context (CustomerDocument/Contract). Using the Value editor will make this job easier.