Importing Parameters from XML into the Infopath form dynamically

S

sreten_v

I have found several articles/postings on this topic but I am still not
able to solve my problem, and I ran out of ideas, so here is what I am
trying to do, hopefully someone can help:

In my local directory (C:\Temp\InfoPath) I have following XML file
("CAA.XML"):

<?xml version="1.0"?>
<NewDataSet>
<Table>
<ACCOUNTNUMBER>1234567890</ACCOUNTNUMBER>
<CHANGETOEXISTING>true</CHANGETOEXISTING>
<CASH>false</CASH>
<LASTNAME>Smith</LASTNAME>
<FIRSTNAME>John</FIRSTNAME>
</Table>
</NewDataSet>

In the same directory I have a simple Infopath form called
"TestTemplate" that has all the 5 fields from the XML file above on it.
I have added a XML based node in my data source (I have no other data
on the form). Now my form has all 5 fields added on it and my data
source tree looks like this:

NewDataSet
Table
ACCOUNTNUMBER
CHANGETOEXISTING
CASH
LASTNAME
FIRSTNAME

I want to be able to run one line command that will perform these 3
actions:
1. Open InfoPath
2. Open the template specified
3. Populate data from the specified XML file.

I came up with the following commands:
"C:\Program Files\Microsoft Office\OFFICE11\INFOPATH.exe" /aggregate
"C:\Temp\InfoPath\CAA.xml" "C:\Temp\InfoPath\TestTemplate.xsn"

This does the work partially - InfoPath and my template open, but
data from XML is not populated (even though I quickly see a message
that some merging is going on).

As someone suggested, I also created the xsl version of my xml file
which I called "parmsToDOM.xsl" (I tried implementing logic to insert
only one field for now - ACCOUNTNUMBER - from the XML file to my form
- but I am not sure if the syntax is correct - this certainly does
not work).

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:agg="http://schemas.microsoft.com/office/infopath/2003/aggregation"
xmlns:target="http://schemas.microsoft.com/office/infopath/2003/aggregation-target"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2003-05-29T20:30:47">

<xsl:template match="/">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>

<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>

<xsl:template match="src:ACCOUNTNUMBER">
<my:field1 agg:select="/my:NewDataSet/my:Table/my:ACCOUNTNUMBER"
agg:action="replace">
<xsl:value-of select="."/>
</my:field1>
</xsl:template>

</xsl:stylesheet>


Finally, I modified my manifest.xsf file by adding following:

<xsf:importParameters enabled="yes">
<xsf:importSource name="" schema="schema.xsd"
transform="parmsToDOM.xsl"></xsf:importSource>
</xsf:importParameters>

However I don't think this file gets read at all as no matter what
kind of change I make to it (I even removed it completely once to see
what happens) Infopath does not complain - and opens the form
normally. How is that possible?

I would really appreciate any help on this as I am not able to proceed
from here.

Thanks

Sreten Vukajlovic
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top