Click here to Skip to main content
15,890,186 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI,

Below is my xml pattern, now i need to bind these xml to xslt.
XML
<Quote>
  <Quotation_Customer>
    <quoteid>Quote1</quoteid>
    <cus_name>xyz</cus_name>
    <cus_address>chennai</cus_address>
    <contact_person>yyyyyyy</contact_person>
    <Quotation_Products>
      <quoteid>Quote1</quoteid>
      <pid>PR1</pid>
      <product_name>aasasaaa</product_name>
    </Quotation_Products>
  </Quotation_Customer>
  <Invoice_Customer>
    <cus_name>xyz</cus_name>
    <contact_person>abcde</contact_person>
  </Invoice_Customer>
  <Invoice_Customer>
    <cus_name>kjkajsd</cus_name>
    <contact_person>adf</contact_person>
  </Invoice_Customer>
</Quote>



XSLT
XML
<xsl:template match="Quote">
    <table>
      <xsl:apply-templates select="Quotation_Customer"></xsl:apply-templates>
    </table>
  </xsl:template>

  <xsl:template match="Quotation_Customer">
    <tr>
      <td>
        <xsl:value-of select="quoteid"/>
      </td>
    </tr>
    <tr>
      <td>
         <xsl:value-of select="cus_name"/>
      </td>
    </tr>
    <tr>
      <td>
        <xsl:value-of select="cus_address"/>
      </td>
    </tr>
    <tr>
      <td>
        <xsl:value-of select="contact_person"/>
      </td>
    </tr>
    <tr>
      <xsl:apply-templates select="Quotation_Products"></xsl:apply-templates>
    </tr>

  </xsl:template>

  <xsl:template match="Quotation_Products">
    <td>
      <xsl:value-of select="pid"/>
    </td>
    <td>
      <xsl:value-of select="product_name"/>
    </td>
    <td>
      <select>
        <xsl:apply-templates select="../Invoice_Customer"></xsl:apply-templates>
      </select>
    </td>
  </xsl:template>

  <xsl:template match="Invoice_Customer">
    <option>
      <xsl:value-of select="../cus_name"/>
    </option>
  </xsl:template>


from the above xslt everything is working fine but that select dropdown is not binding how to match the template..

[edit]Code block corrected[/edit]
Posted
Updated 4-Jan-14 0:29am
v2

1 solution

HI,,

I solved this myself..
Below is the Solution..

XML
<xsl:template match="Quotation_Products">
   <td>
     <xsl:value-of select="pid"/>
   </td>
   <td>
     <xsl:value-of select="product_name"/>
   </td>
   <td>
     <select>
         <xsl:apply-templates select="parent::node()/parent::node()/Invoice_Customer"></xsl:apply-templates>
     </select>
   </td>
   <td>
     <a href="#myModal" data-id="{pid}" data-campid="{quoteid}" class="btn btn-primary" data-toggle="modal">Renewed</a>
   </td>
 </xsl:template>

 <xsl:template match="Invoice_Customer">
   <option value="{cus_name}">
     <xsl:value-of select="cus_name"/>
   </option>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900