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]

Nested <xsl:for-each select="">


I have a problem to get the correct value of first <xsl:for-each select>
when i use nested for-each operation. Below is the xml,xsl,expected results 
and results file for reference.

Expected Result:
ProductID  ProductTitle  Description   Price  ImageLink
  P0001	    Product1	 Product1Desc  22.00  C:/Images/Image1.gif
  P0002     Product2     Product2Desc  25.00  C:/Images/Image2.gif

Result :
ProductID  ProductTitle  Description   Price   ImageLink


XML :

<?xml version="1.0" encoding="UTF-8"?>
<MainRoot>
  <ContentTypeProperty>
    <Record>
      <PropertyName>ProductID</PropertyName>
    </Record>
    <Record>
      <PropertyName>ProductTitle</PropertyName>
    </Record>
    <Record>
      <PropertyName>Description</PropertyName>
    </Record>
    <Record>
      <PropertyName>Price</PropertyName>
    </Record>
    <Record>
      <PropertyName>ImageLink</PropertyName>
    </Record>
  </ContentTypeProperty>
  <ContentTypePropertyData>
    <Record>
      <ProductID>P0001</ProductID>
      <ProductIDAC>YNYY</ProductIDAC>
      <ProductTitle>Product1</ProductTitle>
      <ProductTitleAC>YNYY</ProductTitleAC>
      <Description>ProDuct1Desc</Description>
      <DescriptionAC>YNYY</DescriptionAC>
      <Price>22.00</Price>
      <PriceAC>YNYY</PriceAC>
      <ImageLink>C:/Images/Image1.gif</ImageLink>
      <ImageLinkAC>YNYY</ImageLinkAC>
      <KeyValue>P0001</KeyValue>
    </Record>
    <Record>
      <ProductID>P0002</ProductID>
      <ProductIDAC>YNYY</ProductIDAC>
      <ProductTitle>Product2</ProductTitle>
      <ProductTitleAC>YNYY</ProductTitleAC>
      <Description>Product2Desc</Description>
      <DescriptionAC>YNYY</DescriptionAC>
      <Price>25.00</Price>
      <PriceAC>YNYY</PriceAC>
      <ImageLink>C:/Images/Image2.gif</ImageLink>
      <ImageLinkAC>YNYY</ImageLinkAC>
      <KeyValue>P0002</KeyValue>
    </Record>
  </ContentTypePropertyData>
  <RequestParams>
    <RecordToLoop>20</RecordToLoop>
    <result_per_page>5</result_per_page>
    <cmSessionData>SessionDataObject</cmSessionData>
    <mid>1</mid>
    <AccessControlRequired>Y</AccessControlRequired>
    <PublishingRulesRequired>Y</PublishingRulesRequired>
    <moveto>1</moveto>
    <cid>1</cid>
  </RequestParams>
</MainRoot>

XSL :

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">
  <HEAD>
    <TITLE>Nested for-each</TITLE>
      <META >
         <xsl:attribute name="http-equiv">Content-Type</xsl:attribute>
         <xsl:attribute name="content">text/html; 
charset=gb2312</xsl:attribute>
     </META>
  </HEAD>

<HTML>
<BODY>

<TABLE BORDER="2">
  <TR>
  <xsl:for-each select="MainRoot/ContentTypeProperty/Record">
  <xsl:variable name="Property" select="PropertyName"/>
  <TD>
    <TABLE BORDER="0">
      <TR>
        <TD><xsl:value-of select="$Property"/></TD>
      </TR>

      <xsl:for-each select="MainRoot/ContentTypePropertyData/Record" >
      <TR>
        <TD><xsl:value-of select="*[name()=$Property]"/></TD>
      </TR>
      </xsl:for-each>
    </TABLE>
  </TD>
  </xsl:for-each>

  </TR>

</TABLE>

</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


 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]