|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Insurance Transform (was XSL Tranformation!!)
Here is a more compact, annotated version of the XSLT file. The first version may be clearer in that it is simpler. This version is smaller and may be easier to maintain. <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" encoding="UTF-8" /> <xsl:strip-space elements="*" /> <!-- These three templates output nothing (the way we eliminate unwanted elements from the source document). --> <xsl:template match="Risk[not(@RepeatDet)]" /> <xsl:template match="SeqNumber" /> <xsl:template match="ExistingInsurancePaidBy" /> <!-- End --> <!-- This template outputs the document element --> <xsl:template match="/"> <fields> <xsl:apply-templates /> </fields> </xsl:template> <!-- This template matches the highest-level elements you want to process. --> <xsl:template match="Risk[@RepeatDet]"> <xsl:apply-templates /> </xsl:template> <!-- This template matches all the elements higher up in the document structure than "Risk". --> <xsl:template match="doc|PFG|IDI|DiPolicy|Roles|Insured|Party"> <xsl:apply-templates /> </xsl:template> <!-- This template matches all the source document elements that we want to turn into "field" elements in the output document. --> <!-- Note the use of the "attribute value template (the curly braces). This is how you get the value of a variable into an attribute. --> <!-- Note the use of variables. Each time the template is processed, the variable is re-created. That's how you get around the problem of variables being immutable. --> <xsl:template match="ExistingProductType|ExistingPolNumber|ExistingInsuranceAmt|ExistingInsuranceName|ExistingInsurancePending|ExistingInsuranceEP|ExistingInsuranceInd|ExistingInsuranceBP|ReplacementType"> <xsl:variable name="sn" select="preceding-sibling::SeqNumber[1]" /> <xsl:variable name="lname"><xsl:value-of select="local-name(.)" /></xsl:variable> <field name="{$lname}{$sn}"><value><xsl:value-of select="." /></value></field> </xsl:template> </xsl:stylesheet> -- Charles Knell cknell@xxxxxxxxxx - email
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Cast Your Vote
We need your help – Vote for DataDirect XML Products!
Winners and finalists announced at SOA World Conference in November. Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|







