Xslt 试图删除元素并对结果文档中的元素重新排序
我有以下XML和XSLTXslt 试图删除元素并对结果文档中的元素重新排序,xslt,Xslt,我有以下XML和XSLT 我试图从结果文档中排除NotUsed2元素 我需要对结果进行重新排序,以便AutoTypesetInfo遵循NotUsed3 XML: 0 Pub1 080818 主要 第一 26 A、B、C 08082018 21.70i 9.87i 2 A. 1. A. 0 0708182230 CMYK MAIN@F c@FolioStandard@我@ 1. 1. 0 编辑 12345 描述1 080818 080818 顾客 过程 710.9 144 EPS 0 0 140
0
Pub1
080818
主要
第一
26
A、B、C
08082018
21.70i
9.87i
2
A.
1.
A.
0
0708182230
CMYK
MAIN@F
c@FolioStandard@我@
1.
1.
0
编辑
12345
描述1
080818
080818
顾客
过程
710.9
144
EPS
0
0
1404.03
0:5-60
A.
2.
A.
0
0708182230
CMYK
MAIN@1
c@FolioStandard@我@
1.
1.
0
混合的
152345
描述
080818
080818
顾客
000K
351.9
360
EPS
0
0
1188.03
12345
描述
080818
080818
顾客
过程
351.9
360
EPS
0
358.99
1188.03
0:5-60
XSL:
在生成的页面节点中应为:
<Page>
<PhysicalBook>A</PhysicalBook>
<BookPageNumber>1</BookPageNumber>
<Desk>A</Desk>
<SubDesk/>
<SpreadPage>0</SpreadPage>
<Status/>
<Deadline>0708182230</Deadline>
<PagePrintInfo/>
<Cmyk>CMYK</Cmyk>
<Spot1/>
<Spot2/>
<Spot3/>
<CyanFilm/>
<MagFilm/>
<YelFilm/>
<BlackFilm/>
<Spot1Film/>
<Spot2Film/>
<Spot3Film/>
<PageId>MAIN@F</PageId>
<TemplatePage>
<Content>c@FolioStandard@i@</Content>
<Layout></Layout>
</TemplatePage>
<ProdForm/>
<TextSourceDir/>
<TextSourcePage/>
<RunningPage/>
<CmyDeadline/>
<ColorGrp/>
<AdRules>1</AdRules>
<CustChar/>
<CustDate/>
<Active>1</Active>
<NoMaster>0</NoMaster>
<Cust2/>
<PageType>EditorialOnly</PageType>
<Cust4/>
<Cust5/>
<Cust6/>
<Cust7/>
<Cust8/>
<Cust9/>
<Cust10/>
<Desk2/>
<Desk2NewsHole/>
<Desk2Placement/>
<Cust11/>
<NotUsed3/>
<AutoTypesetInfo>0:5-60</AutoTypesetInfo>
<Ad>
<BookingNumber>12345</BookingNumber>
<Description>Desc1</Description>
<AdRelatedInfo> </AdRelatedInfo>
<FirstPubDate>080818</FirstPubDate>
<LastPubDate>080818</LastPubDate>
<Customer>Customer</Customer>
<AdColor>Proces</AdColor>
<AdWidth>710.9</AdWidth>
<AdHeight>144.0</AdHeight>
<MatType>EPS</MatType>
<AdType>0</AdType>
<AdPos>
<XPos>0.00</XPos>
<YPos>1404.03</YPos>
</AdPos>
<AdProdInfo/>
<AdNotUsed2/>
<AdNotUsed3/>
<AdCust1/>
<AdCust2/>
<AdCust3/>
</Ad>
</Page>
A.
1.
A.
0
0708182230
CMYK
MAIN@F
c@FolioStandard@我@
1.
1.
0
编辑
0:5-60
12345
描述1
080818
080818
顾客
过程
710.9
144
EPS
0
0
1404.03
我无法获取排除NotUsed2元素的代码。
我不确定从哪里开始处理节点内元素的重新排序问题
任何帮助都将不胜感激。您的
NotUsed2
不会被删除,因为您没有考虑元素位于XML中的默认命名空间中这一事实。XSLT正在查找没有名称空间的元素
您已经在XSLT中声明了相关名称空间,因此只需要在模板匹配中使用相关前缀
<xsl:template match="cci:NotUsed2" />
您还需要一个模板来确保AutoTypesetInfo
不会在当前位置被复制
<xsl:template match="cci:AutoTypesetInfo" />
试试下面的XSLT
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:cci="http://www.ccieurope.com/xmlns/CCIPlanner"
exclude-result-prefixes="msxsl cci"
>
<xsl:output indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<!-- If element name match on NotUsed2, exclude from result -->
<xsl:template match="*[local-name()='NotUsed2']" />
</xsl:stylesheet>
很抱歉延迟返回标记。谢谢你的指导。非常感谢。
<xsl:template match="cci:NotUsed3">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
<xsl:copy-of select="../cci:AutoTypesetInfo" />
</xsl:template>
<xsl:template match="cci:AutoTypesetInfo" />
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:cci="http://www.ccieurope.com/xmlns/CCIPlanner"
exclude-result-prefixes="msxsl cci">
<xsl:output indent="yes"/>
<xsl:template match="@* | node()" name="identity">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<!-- If element name match on NotUsed2, exclude from result -->
<xsl:template match="cci:NotUsed2" />
<xsl:template match="cci:NotUsed3">
<xsl:call-template name="identity" />
<xsl:copy-of select="../cci:AutoTypesetInfo" />
</xsl:template>
<xsl:template match="cci:AutoTypesetInfo" />
</xsl:stylesheet>
<xsl:template match="cci:AutoTypesetInfo[../cci:NotUsed3]" />
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:cci="http://www.ccieurope.com/xmlns/CCIPlanner"
exclude-result-prefixes="msxsl cci"
>
<xsl:output indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<!-- If element name match on NotUsed2, exclude from result -->
<xsl:template match="*[local-name()='NotUsed2']" />
</xsl:stylesheet>