|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: XSL Transformation!!
> -----Original Message----- > From: Kalkunda, Venkat <Kalkunda.Venkat@xxxxxxxxxxxxx> > Sent: Mon, 27 Dec 2004 08:40:33 -0600 > To: <cknell@xxxxxxxxxx> > Subject: XSL Transformation!! > > > I have attached 2 xml files. The first XML file contains the data with the complete tag > structure in the actual input file but just the part I want help with transformation. And teh > DesiredOutput.xml file shows how the output file should look like after the transformation. > The input and output are XML files. Does this represent the mapping between input and output elements you want? SeqNumber -> NULL ExistingProductType -> ExistingProductType(x) ExistingPolNumber -> ExistingPolNumber(x) ExistingInsuranceAmt -> ExistingInsuranceAmt(x) ExistingInsuranceName -> ExistingInsuranceName(x) ExistingInsurancePending -> ExistingInsurancePending(x) ExistingInsuranceEP -> ExistingInsuranceEP(x) ExistingInsuranceInd -> ExistingInsurancePaidByInd(x) ExistingInsuranceBP -> ExistingInsuranceBP(x) ExistingInsuranceReplacement1 -> ExistingInsuranceReplacement(x) Where (x) represents a sequential integer indicating the position of the element in the source document relative to all other similarly-named elements? > Also I have another question, can you tell how we can declare variables in > XSLT, such that we can use it at various places in our transformation and if > the tag, that I am populationg this variable with, does not exist in the input > file how do I assign it a default value? First, watch your language. XML documents (at least once they have been parsed) have no tags. They have nodes of various types. The kind of node you are describing is an "element node". XSLT variables are simple, but likely to be confusing to a Java programmer in that once declared, they are immutable. They are, in a sense, like declaring a Java variable to be "Static". If you want the variable to be accessible from any point in the transformation, declare it outside the first match template, e.g., <?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="*" /> <xsl:variable name="johnson"> <comedian> <name>Raymond J. Johnson, Jr.</name> <type>standup</type> </comedian> </xsl:variable> Thereafter, you can refer to the variable as "$johnson". You can get the value of the "type" element with an expression like this: <xsl:value-of select="$johnson/comedian/type" /> -- Charles Knell cknell@xxxxxxxxxx - email
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! 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
|

Cart








