This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: How to get XSL transform this XML


> 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@ntlworld.com
work: Michael.Kay@softwareag.com


>
> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]