将架构信息添加到xsl转换输出

时间:2010-09-13 12:35:10

标签: xml xslt schema

在xml文档上执行xsl转换时,我需要将以下代码段添加到xml输出中:

<?mso-infoPathSolution name="urn:schemas-microsoft-com:office:infopath:ResourceForm:-myXSD-2010-08-09T08-39-43" solutionVersion="1.0.0.68" productVersion="14.0.0.0" PIVersion="1.0.0.0" href="http://somewhere.com/ResourceForm.xsn"?>
<?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.3"?>
<?mso-infoPath-file-attachment-present?>

谁能告诉我怎么做?

2 个答案:

答案 0 :(得分:2)

<xsl:processing-instruction name="mso-infoPathSolution"
  select="('name=&quot;urn:schemas-microsoft-com:office:infopath:ResourceForm:-myXSD-2010-08-09T08-39-43&quot;', 'solutionVersion=&quot;1.0.0.68&quot;','productVersion=&quot;14.0.0.0&quot;','PIVersion=&quot;1.0.0.0&quot;','href=&quot;http://somewhere.com/ResourceForm.xsn&quot;')"/>

应该为你做第一个,其余的应该是显而易见的。

答案 1 :(得分:0)

如果您需要XSLT 1.0解决方案,可以采用以下方法:

<xsl:processing-instruction name="mso-infoPathSolution">name="urn:schemas-microsoft-com:office:infopath:ResourceForm:-myXSD-2010-08-09T08-39-43" solutionVersion="1.0.0.68" productVersion="14.0.0.0" PIVersion="1.0.0.0" href="http://somewhere.com/ResourceForm.xsn"</xsl:processing-instruction>

将输出:

<?mso-infoPathSolution name="urn:schemas-microsoft-com:office:infopath:ResourceForm:-myXSD-2010-08-09T08-39-43" solutionVersion="1.0.0.68" productVersion="14.0.0.0" PIVersion="1.0.0.0" href="http://somewhere.com/ResourceForm.xsn"?>

指令xsl:processing-instruction的内容是可选的。对于只有名称的PI,只需跳过内容:

<xsl:processing-instruction name="mso-infoPath-file-attachment-present"/>

将产生:

<?mso-infoPath-file-attachment-present?>