I have created a form that will be used to submit cXML structured files to a
supplier network. However, I need to remove some of the extra information
Infopath includes at the top of the xml file and add a DOCTYPE public
reference.
My current file output looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<?mso-infoPathSolution solutionVersion="1.0.0.44" productVersion="11.0.6357"
PIVersion="1.0.0.0" href="file:///C:\Oracle\xml\infopath\invoice.xsn"
name="urn:schemas-microsoft-com:office:infopath:invoice:" ?>
<?mso-application progid="InfoPath.Document"?>
<cXML version="1.0" payloadID="user.payloadID"
timestamp="2005-08-17T15:08:52"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-08-16T14:33:09"
xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"
xml:lang="en-us">
and I would like it to look like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cXML SYSTEM
"http://xml.cXML.org/schemas/cXML/1.2.013/InvoiceDetail.dtd">
<cXML version="1.0" payloadID="user.payloadID"
timestamp="2005-08-17T15:08:52">
Can anyone point me in the right direction of how to go about changing this?
ChrisB - 18 Aug 2005 22:34 GMT
Help! Does anyone have any info on how to do what I have described in my
original post? At least tell me if it is impossible or not so I can quit
banging my head against the wall.
At the very least, is it possible to just add the line below to the top of
the resulting xml form file (right after the xml declaration). I have a
custom submit button and was hoping I could put some code in that would add
the line just before calling the submit function.
<!DOCTYPE cXML SYSTEM
"http://xml.cXML.org/schemas/cXML/1.2.013/InvoiceDetail.dtd">
Roland - 20 Sep 2005 12:57 GMT
further to this OP:
http://groups.google.com/group/microsoft.public.infopath/msg/9d7248f4adc98286
hi chris, i suggest that you use a custom submit handler, and transform
the XDocument xml using the following XSLT:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--================================================================================
-->
<!--
this stylesheet removes:
mso-infoPathSolution processing instruction
mso-application processing instruction
and adds:
DOCTYPE declaration
-->
<!--
================================================================================
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"
doctype-system="http://xml.cXML.org/schemas/cXML/1.2.013/InvoiceDetail.dtd"/>
<xsl:template match="/">
<!-- select all nodes and only attributes in the default namespace
-->
<xsl:apply-templates select="@*[namespace-uri()='']|node()"/>
</xsl:template>
<!-- copy any other element type node in any other namespace -->
<xsl:template match="node()">
<!-- redefine the element: note that all other namespace declarations
are omitted -->
<xsl:element name="{local-name()}" namespace="{namespace-uri()}">
<!-- match any child attribute or node -->
<xsl:apply-templates select="@*[namespace-uri()='']|node()"/>
</xsl:element>
</xsl:template>
<!-- copy any other non-element type nodes -->
<xsl:template match="@*|text()|comment()">
<xsl:copy/>
</xsl:template>
<!-- delete InfoPath PI node -->
<xsl:template match="processing-instruction('mso-infoPathSolution')">
<!-- output nothing -->
</xsl:template>
<!-- delete Office ProgID PI node -->
<xsl:template match="processing-instruction('mso-application')">
<!-- output nothing -->
</xsl:template>
</xsl:stylesheet>