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

RE: How to get XSL transform this XML

Subject: RE: How to get XSL transform this XML
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Tue, 26 Mar 2002 15:09:47 -0000
linux xml transform xsl download
> I need XSL to transform the following XML. Could some guru
> help me out ?

Are you really stuck with this XML design? Having elements

<condition1>..
<condition2>..
<condition3>..

is an appalling way of marking up a document; far better would be

<condition number="1">
<condition number="2">
<condition number="3">

(or just leave the numbers implicit).

Having said that, it's quite possible to do:

<xsl:template match="*[starts-with(name(), 'condition')] and .='CLOSING
CONDITION'">
<xsl:copy-of select="."/>
...
</xsl:template>

<xsl:template match="*[starts-with(name(), 'condition') and
preceding-sibling::*[starts-with(name(), 'condition')] and .='CLOSING
CONDITION']">
<xsl:element name="condition{substring-after(name(), 'condition')+3">
...

But it's not nice.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx


>
> Below is a sample XML that I want to transform, and the
> description of the
> problem:
>
> <?xml version="1.0"?>
> <DocumentRequest>
>   <Director>
>     <DocumentName>UnderwritingAnalysisPage1</DocumentName>
>     <DeliveryMedium>browser</DeliveryMedium>
>     <ApplicationId>15</ApplicationId>
>     <PostPay>no</PostPay>
>   </Director>
>   <DocumentDetails>
>     <BorrowerName>WALZER, CLIFFORD S</BorrowerName>
>     <LoanStatus>APPROVED</LoanStatus>
>      .
>      .
>     <ConditionText1>PRIOR TO APPROVAL CONDITIONS - UGSI TO
> REVIEW:</ConditionText1>
>     <ConditionText2>     </ConditionText2>
>     <ConditionText3>PRIOR TO DOC CONDITIONS - UGSI TO
> REVIEW:</ConditionText3>
>     <ConditionText4>     </ConditionText4>
>     <ConditionText5>PRIOR TO CLOSING CONDITIONS - UGSI TO
> REVIEW:</ConditionText5>
>     <ConditionText6>03/14/2002 _____ THANK YOU FOR CHOOSING
> UNITED GUARANTY.
>   PLEASE INCLUDE A COPY OF </ConditionText6>
>     <ConditionText7>                 THIS</ConditionText7>
>      .
>      .
>     <ConditionText15>CLOSING CONDITIONS:</ConditionText15>
>     <ConditionText16>                 X FINAL SIGNED
> T-I-L</ConditionText16>
>     <ConditionText17>                 X FILE MUST CLOSE AS A 30 YEAR
> RATE/TERM REFINANCE</ConditionText17>
>      .
>      .
>     <ConditionText44> </ConditionText44>
>   </DocumentDetails>
> </DocumentRequest>
>
> The tag value "CLOSING CONDITIONS:" can appear as value of any of the
> ConditionText tags, but after the "PRIOR CONDITIONS".
> The XSL stylesheet should locate the "CLOSING CONDITIONS:"
> value, and insert
> 3 new predefined fixed ConditionText nodes after
> that node. All the remaining ConditionText nodes will show
> this change in
> the result tree by having their count incremented as
> shown in the transformed XML below:
>
> <?xml version="1.0"?>
> <DocumentRequest>
>   <Director>
>     <DocumentName>UnderwritingAnalysisPage1</DocumentName>
>     <DeliveryMedium>browser</DeliveryMedium>
>     <ApplicationId>15</ApplicationId>
>     <PostPay>no</PostPay>
>   </Director>
>   <DocumentDetails>
>     <BorrowerName>WALZER, CLIFFORD S</BorrowerName>
>     <LoanStatus>APPROVED</LoanStatus>
>      .
>      .
>     <ConditionText1>PRIOR TO APPROVAL CONDITIONS - UGSI TO
> REVIEW:</ConditionText1>
>     <ConditionText2>     </ConditionText2>
>     <ConditionText3>PRIOR TO DOC CONDITIONS - UGSI TO
> REVIEW:</ConditionText3>
>     <ConditionText4>     </ConditionText4>
>     <ConditionText5>PRIOR TO CLOSING CONDITIONS - UGSI TO
> REVIEW:</ConditionText5>
>     <ConditionText6>03/14/2002 _____ THANK YOU FOR CHOOSING
> UNITED GUARANTY.
>   PLEASE INCLUDE A COPY OF </ConditionText6>
>     <ConditionText7>                 THIS</ConditionText7>
>      .
>      .
>     <ConditionText15>CLOSING CONDITIONS:</ConditionText15>
>     <ConditionText16>                 X This is Standard Condition
> 1</ConditionText16> <!-- These 3 conditions get inserted -->
>     <ConditionText17>                 X This is Standard Condition
> 2</ConditionText17>
>     <ConditionText18>                 X This is Standard Condition
> 3</ConditionText18>
>     <ConditionText19>                 X FINAL SIGNED
> T-I-L</ConditionText19>
>            <!-- ConditionText16 now becomes Condition19, and
> so on; the
> value for the node remains the same -->
>     <ConditionText20>                 X FILE MUST CLOSE AS A 30 YEAR
> RATE/TERM REFINANCE</ConditionText20>
>      .
>      .
>     <ConditionText47> </ConditionText47>
>   </DocumentDetails>
> </DocumentRequest>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at
http://explorer.msn.com/intl.asp.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.