我有下面的XML文檔清除從節點值和XML文件使用XSLT
<?mso-infoPathSolution name="urn:schemas-microsoft-com:office:infopath:TCM-TCP:-myXSD-2012-02-20T14-33-22" solutionVersion="1.0.0.65" productVersion="14.0.0.0" PIVersion="1.0.0.0" href="https://devcoop.oceanspray.com/sites/TCM2/FormServerTemplates/TCM-TCP.xsn"?>
<?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.3"?>
<my:myFields xml:lang="en-US" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-02-20T14:33:22" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003">
<my:Header>
<my:ProjectName>Something</my:ProjectName>
<my:ProjectCreationDate>2/21/2012 12:00 AM</my:ProjectCreationDate>
</my:Header>
<my:Details>
<my:DescriptionOfProposal>
Will be filled in when saved<html xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml"><p>testestdsgsgasfgf a<strong>asdf </strong>adf asdf asdf as</p></html>
</my:DescriptionOfProposal>
<my:PurposeOfChange>Will be filled in when saved</my:PurposeOfChange>
</my:Details>
</my:myFields>
我想運行此文件,將清除出我的價值在XSLT文件:DescriptionOfPropsal節點。它將完全清除文本和子節點。我有以下XSLT樣式表
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="urn:schemas-microsoft-com:office:infopath:TCM-TCP:-myXSD-2012-02-20T14-33-22"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="//my:DescriptionOfProposal">
<my:DescriptionOfProposal>
</my:DescriptionOfProposal>
</xsl:template>
</xsl:stylesheet>
但是,這似乎並沒有工作。我用它做了一堆測試,我相信它與節點上的命名空間有關,因爲我可以對另一個沒有命名空間的簡單文檔執行相同類型的轉換,並且可以使其工作。
你會介意查看我的答案嗎? :) – 2012-02-28 04:54:52
謝謝你完美的作品 – 2012-02-28 13:27:01
@PaulCavacas:不客氣。 – 2012-02-28 14:23:53