tags:

views:

24

answers:

2

Hi

When performing an xsl transformation on an xml document, I need to add the following snippet to the xml output:

<?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"?&gt;
<?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.3"?>
<?mso-infoPath-file-attachment-present?>

Can anyone tell me how to do this?

+2  A: 
<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&amp;quot;')"/&gt;

should do the first one for you, the rest should hopefully then be obvious.

Nick Jones
@Nick Jones: I think this works only in XSLT 2.0
Alejandro
+1 for a correct and complete answer.
Dimitre Novatchev
@Alejandro: Why? `<xsl:processing-instruction>` is a valid XSLT 1.0 instruction.
Dimitre Novatchev
`xsl:processing-instruction` is a XSLT 1.0 instruction but the suggested implementation will only work in XSLT 2.0 because of two reasons: (1) It uses the `@select` attribute which is only available in XSLT 2.0, (2) The sequence used in the `@select` attribute cannot be undestood by a XSLT 1.0 parser.
Per T
A: 

If you're in need of a XSLT 1.0 solution, this is the way to go:

<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"&lt;/xsl:processing-instruction&gt;

Which will output:

<?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"?&gt;

The content of the instruction xsl:processing-instruction is optional. For a PI with only a name, just skip the content:

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

Will produce:

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