Discussions

XML & Web services: Help needed to make an XSLT for the given XML

  1. Help needed to make an XSLT for the given XML (2 messages)

    Hello everybody.
    It would be great if someone can help...

    I am new to XSLT. I have been given a small task to make an XSLT for the given XML below.
    The output of the XML in IE Browser should look something like this...
    --------------------------------------
    Borrower Name : John Homeowner
    SSN : 234-23-2342
    Date of birth : ... and so on....
    --------------------------------------

    <LOAN_APPLICATION>
    <BORROWER BorrowerID="B300405000" JointAssetBorrowerID="B500222000" _FirstName="John " _LastName="Homeowner " _SSN="300405000" _PrintPositionType="Borrower" JointAssetLiabilityReportingType="Jointly" _UnparsedName="John Homeowner ">
    <_MAIL_TO/>
    <_RESIDENCE _StreetAddress="4420 E. Douglas Ave. " _City="Higley " _State="AZ" _PostalCode="85236 " BorrowerResidencyType="Current"/>
    <CURRENT_INCOME IncomeType="Base" _MonthlyTotalAmount="4100.00"/>
    <CURRENT_INCOME IncomeType="MilitaryBasePay" _MonthlyTotalAmount="250.00"/>
    <DECLARATION BankruptcyIndicator="N" CitizenshipResidencyType="USCitizen" HomeownerPastThreeYearsType="No" IntentToOccupyType="Yes"/>
    <EMPLOYER CurrentEmploymentMonthsOnJob="0 " CurrentEmploymentYearsOnJob="1 " EmploymentBorrowerSelfEmployedIndicator="Y" EmploymentCurrentIndicator="Y" EmploymentPrimaryIndicator="Y"/>
    <GOVERNMENT_MONITORING RaceNationalOriginRefusalIndicator="N">
    <HMDA_RACE/>
    </GOVERNMENT_MONITORING>
    <PRESENT_HOUSING_EXPENSE HousingExpenseType="Rent" _PaymentAmount="892.00"/>
    <PRESENT_HOUSING_EXPENSE HousingExpenseType="FirstMortgagePrincipalAndInterest"/>
    <_NEAREST_LIVING_RELATIVE/>
    </BORROWER>
    </LOAN_APPLICATION>

    Threaded Messages (2)

  2. The following is enough to show the full name of the borrower:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

    <xsl:template match="/">
      <html>
      <body>
      <h1>Loan application</h1>
      <xsl:apply-templates select="*"/>
      </body>
      </html>
    </xsl:template>

    <xsl:template match="LOAN_APPLICATION">
      <table border="1">
        <xsl:apply-templates select="*"/>
      </table>
    </xsl:template>

    <xsl:template match="BORROWER">
      <tr>
      <th>Borrower name:</th>
      <td><xsl:value-of select="@_FirstName"/> <xsl:value-of select="@_LastName"/></td>
      </tr>
    </xsl:template>

    </xsl:stylesheet>

    Other data can be output in a similar way.

    I am not sure whether asking so basic and generic questions is actually a good thing. I advise you to read materials like http://www.ibiblio.org/xml/books/bible2/chapters/ch17.html, which was good, although I reckon it is getting obsolete by now.

    Regards
  3. Thanks[ Go to top ]

    Thanks Javier
    I am very new to XSL and XML.. Since that was my first day, I thought of getting a quick answer hence posted the question. I worked out the solution myself using XSLT long back and realised, XSL is not as powerful tool as any other language like Java. So have decided to go J2EE way.

    I am sure this link will be helpful for even new bies like me.
    Thanks
    Rakesh