我有XML文檔這樣的:XSLT子元素
<OrdersSchedulePDFView>
<OrdersSchedulePDFViewRow>
<Items>
<ItemDesc>Content1</ItemDesc>
<ItemDesc>Content2</ItemDesc>
</Items>
<Locations>
<LocName>Content3</LocName>
<LocName>Content4</LocName>
</Locations>
</OrdersSchedulePDFViewRow>
</OrdersSchedulePDFView>
請給我一個例子XSL文件,在那裏我可以通過模板得到ItemDesc和LOCNAME元素。在此先感謝 這是我的xsl:
<?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">
<xsl:template match="Locations">
<xsl:copy>
<xsl:apply-templates select="LocName"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Items">
<xsl:copy>
<xsl:apply-templates select="ItemDesc"/>
</xsl:copy>
</xsl:template>
</fo:flow>
</fo:page-sequence>
</xsl:for-each>
</fo:root>
</xsl:template>
</xsl:stylesheet>
你究竟在做什麼?你可以嘗試''(如果元素上沒有我們可能看不到的名稱空間),但模板應該做什麼? –
我需要打印ItemDesc和LocName元素。但我無法通過讓他們的 的 –
你爲什麼不發表您的嘗試,所以我們可以解決這個問題,而不是有從頭開始爲您編寫代碼。此外,請顯示您期望得到的**精確**輸出。 –