XSLT-FO para-cada

Este é o meu xml:

<OrdersSchedulePDFView>
 <OrdersSchedulePDFViewRow>
   <Locations>
     <LocName>Text1</LocName>
     <LocName>Text2</LocName>         
   </Locations>
 </OrdersSchedulePDFViewRow>     
</OrdersSchedulePDFView>

e isto é um fragmento do meu ficheiro xslt-fo:

<xsl:template match="OrdersSchedulePDFView">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">        
        <xsl:for-each select="./OrdersSchedulePDFViewRow">        
        <fo:page-sequence master-reference="all">            
            <fo:flow flow-name="xsl-region-body">                       
                    <xsl:for-each select="Locations">                   
                     <xsl:apply-templates select="."/>                  
                    </xsl:for-each>                             
            </fo:flow>
        </fo:page-sequence>
        </xsl:for-each>
    </fo:root>
</xsl:template>
<xsl:template match="Locations">
    <fo:block text-align="left" font-family="Arial">
        <fo:inline font-weight="bold"><xsl:value-of select="LocName"/></fo:inline>
    </fo:block>  
</xsl:template>
</xsl:stylesheet>
Mas em PDF só tenho um LocName. Como posso obter todos os elementos do LocName?

2 answers

Com base na sua actualização: dado que aparentemente não tem nenhum código a Adicionar para um elemento Locations, pode encurtar o seu código alterando:

<xsl:apply-templates select="Locations"/>

To:

<xsl:apply-templates select="Locations/LocName"/>

E depois fazer:

<xsl:template match="LocName"> 
    <fo:block text-align="left" font-family="Arial"> 
        <fo:inline font-weight="bold">
            <xsl:value-of select="."/>
        </fo:inline> 
    </fo:block> 
</xsl:template>
 2
Author: michael.hor257k, 2017-04-27 08:16:15

O código correcto para mim:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">   
<xsl:template match="OrdersSchedulePDFView">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">        
        <xsl:for-each select="./OrdersSchedulePDFViewRow">        
        <fo:page-sequence master-reference="all">            
            <fo:flow flow-name="xsl-region-body">
                    <fo:block font-weight="bold" background-color="black" color="white" padding="2pt" font-family="Arial">Stores</fo:block>
                    <fo:block text-align="left" font-family="Arial">
        <fo:inline font-weight="bold"><xsl:apply-templates select="Locations"/></fo:inline>
    </fo:block>                             
            </fo:flow>
        </fo:page-sequence>
        </xsl:for-each>
    </fo:root>
</xsl:template>
<xsl:template match="Locations">
    <xsl:for-each select="./LocName">
    <fo:block text-align="left" font-family="Arial">
        <fo:inline font-weight="bold"><xsl:value-of select="."/></fo:inline>
    </fo:block>
    </xsl:for-each> 
</xsl:template>
 1
Author: Вячеслав Кошман, 2017-04-27 08:10:15