[Home] [By Thread] [By Date] [Recent Entries]
Hi, I ran the following XSLT and XML in two ways - Via the xslt ant task (comes with ant 1.7) and through XSLT FOP. I got two very different results. Using the ant task, the key did not work, but using XSLT FOP (which is probably Xalan), I managed to get what I expected. To add to my weirdness, on the Ant task, if I used <xsl:message><xsl:copy-of select="key('getComponent',1)"/></xsl:message> instead of <xsl:message><xsl:copy-of select="key('getComponent', $component_id)"/></xsl:message> I got the expected result. Something is obviously busted. Is it the xslt ant task? Also, any thought as to why the contents of the Groups section appears in the fo:layout-master-set? Thanks. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:datetime="http://exslt.org/dates-and-times" xmlns:str="http://exslt.org/strings" > <xsl:import href="styling.xslt"/> <xsl:key name="getComponent" match="/Vouchers/Components/Component" use="@Id"/> <xsl:variable name="components" select="/Vouchers/Components"/> <xsl:template match="Vouchers"> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:layout-master-set> <xsl:apply-templates select="Components/Component" mode="page_masters"> </xsl:apply-templates> </fo:layout-master-set> </fo:root> </xsl:template> <xsl:template match="Component" mode="page_masters">
<xsl:apply-templates select="*" mode="page_masters_comp">
<xsl:with-param name="component_id" select="@Id"/>
</xsl:apply-templates>
</xsl:template><xsl:template match="HotelStay" mode="page_masters_comp"> <xsl:param name="component_id"/> <xsl:message><xsl:value-of select="$component_id"/></xsl:message> <xsl:message><xsl:copy-of select="key('getComponent', $component_id)"/></xsl:message> <xsl:for-each select="key('getComponent', $component_id)/Groups/Group"> <xsl:variable name="master_name" select="concat('component-', $component_id, '-room-', @Id)"/> <fo:simple-page-master master-name="$master_name"> <xsl:call-template name="page_definition"/> <fo:region-body region-name="{$master_name}-body"> <xsl:call-template name="region_body_styling"/> </fo:region-body> <fo:region-before region-name="hotel-top"> <xsl:call-template name="region_before_styling"/> </fo:region-before> <fo:region-after region-name="voucher-conditions"> <xsl:call-template name="region_after_stying"/> </fo:region-after> </fo:simple-page-master> </xsl:for-each> </xsl:template> </xsl:stylesheet> ====== XML ====== <Vouchers>
<Components>
<Component Id="1">
<HotelStay></HotelStay> <Groups> <Group Id="1"> <Description>A room with no view</Description> <ConfirmationId>KASDF-123</ConfirmationId> </Group> <Group Id="2"> <Description>A room with a view</Description> </Group> </Groups> </Component> </Components> </Vouchers>
|

Cart



