My XML schema defines a customer to be of type UK or Non-UK European making use of xsi:type.
The difference between the complex UK and Non-UK European customer types is they have an additional TWO extra fields from the standard customer type.
UK customer additionaly have CustomerCounty & CustomerPostcode
Non-UK European have CustomerAddressline5(optional) & Timezone(I dont need to print this)
However in my XSL I'm hardcoding the selecting of element names in (see code below).
I've looked at <xsl:if> but dont know how to compare the complex xsi type.
Can anyone help please to suggest away I only print the fields based on the xsi type?
Also as elemnt addresslline5 is optional for complex type NonUKEuropean customer is there a way to check if the field is present i.e. nulls before selectign the value?
I guess I could just reference all fields and if there empty or not present they wont print, but I'm sure there's a much better solution outthere.
Thanks
Rob
Extract from XML file.
Expand|Select|Wrap|Line Numbers
- <Customer xsi:type="UKCustomer">
- <CustomerName>Ford Motors</CustomerName>
- <CustomerCode>123456789A</CustomerCode>
- <CustomerAddressLine1>10 Harvard Road</CustomerAddressLine1>
- <CustomerAddressLine2>Fenton</CustomerAddressLine2>
- <CustomerAddressLine3>Stoke-on-Trent</CustomerAddressLine3>
- <CustomerAddressLine4>Staffordshire</CustomerAddressLine4>
- <CustomerCountry>United Kingdom</CustomerCountry>
- <CustomerSigneeName>Trevor Thames</CustomerSigneeName>
- <CustomerSigneeSignature>T.Thames</CustomerSigneeSignature>
- <CustomerPostCode>ST2 9DS</CustomerPostCode>
- </Customer>
Expand|Select|Wrap|Line Numbers
- <td align="justify" valign="top">
- <xsl:value-of select="my:PODBatch/my:POD/my:Customer/my:CustomerName"/><br/>
- <xsl:value-of
- select="my:PODBatch/my:POD/my:Customer/my:CustomerAddressLine1"/><br/>
- <xsl:value-of
- select="my:PODBatch/my:POD/my:Customer/my:CustomerAddressLine2"/><br/>
- <xsl:value-of
- select="my:PODBatch/my:POD/my:Customer/my:CustomerAddressLine3"/><br/>
- <xsl:value-of
- select="my:PODBatch/my:POD/my:Customer/my:CustomerAddressLine4"/><br/>
- <xsl:value-of
- select="my:PODBatch/my:POD/my:Customer/my:CustomerCountry"/><br/>
- <xsl:value-of
- select="my:PODBatch/my:POD/my:Customer/my:CustomerPostcode"/><br/>
- </td>