Thanks in advance for your time. I have a deeply nested XML whose XSLT 1.0 transformation I need to perform (for pdf generation). I’m pasting the XML partially and I apologize for it already!
I have re-tweaked the XML as below based off a couple of answers and I realized I bumped into more issues. Thank you for your patience.
Please let me know if any additional clarification is needed.
INPUT XML:
<Reports>
<Report>
<ReportID>R123</ReportID>
<ReportName>R123Name</ReportName>
<PurchaseTypes>
<PurchaseType>
<Name>Purchase Type 2</Name>
<Areas>
<Area>
<AreaType>American</AreaType>
<AreaName>IL</AreaName>
<SaleDetails>
<SaleDetail>
<SaleDetailID>
SD45
</SaleDetailID>
<Amount>
177.3
</Amount>
</SaleDetail>
<SaleDetail>
<SaleDetailID>
SD56
</SaleDetailID>
<Amount>
123
</Amount>
</SaleDetail>
</SaleDetails>
</Area>
<Area>
<AreaType>American</AreaType>
<AreaName>MN</AreaName>
<SaleDetails>
<SaleDetail>
<SaleDetailID>
SD19
</SaleDetailID>
<Amount>
19
</Amount>
</SaleDetail>
</SaleDetails>
</Area>
</Areas>
</PurchaseType>
</PurchaseTypes>
</Report>
</Reports>
Output needed similar to the image below
Sample Image 2:
https://picasaweb.google.com/lh/photo/hxTUY6Qv_9eJyvxQ-UhQutMTjNZETYmyPJy0liipFm0?feat=directlink
@DevNull, this is what I was trying:
<xsl:template match="Report">
<xsl:apply-templates select="ReportID|PurchaseTypes/PurchaseType"></xsl:apply-templates>
</xsl:template>
<xsl:template match="PurchaseType">
<xsl:apply-templates select="Name|Areas/Area/AreaType"></xsl:apply-templates>
</xsl:template>
But I’m seeing the area type American twice.
Something like this:
R123
Purchase Type 2
American
American
Looking at your input XML and the excel image of the desired output, it still doesn’t look like you need grouping. The XML seems to already be organized the way you need your report(s) to be formatted.
Here’s an example using XSL-FO to create the PDF.
Your XML input:
Transformed with this stylesheet:
Produces this PDF:
Hopefully what’s happening isn’t lost in the FO markup.