【问题标题】:Adding schema information to xsl transformation output将模式信息添加到 xsl 转换输出
【发布时间】:2010-09-13 21:39:18
【问题描述】:

在对xml文档进行xsl转换时,需要在xml输出中添加如下sn-p:

<?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?>

谁能告诉我怎么做?

【问题讨论】:

标签: xml xslt schema


【解决方案1】:
<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;')"/>

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

【讨论】:

  • @Alejandro:为什么? &lt;xsl:processing-instruction&gt; 是有效的 XSLT 1.0 指令。
  • xsl:processing-instruction 是 XSLT 1.0 指令,但建议的实现仅适用于 XSLT 2.0,原因有两个:(1)它使用仅在 XSLT 2.0 中可用的 @select 属性,( 2) @select 属性中使用的序列不能被 XSLT 1.0 解析器解析。
【解决方案2】:

如果您需要 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?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-20
    • 1970-01-01
    • 2021-01-27
    • 2012-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多