[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Insurance Transform (was XSL Tranformation!!)

Subject: RE: Insurance Transform (was XSL Tranformation!!)
From: cknell@xxxxxxxxxx
Date: Wed, 29 Dec 2004 15:31:46 -0500
element reinsurance
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.