These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Removing non populated fields within a form when converting to XML

DeeperdownUK
Registered: Aug 12 2010
Posts: 8

Hi,
I have painstakingly managed to complete a form which I must say really works well and if we can manipulate the data will save us hours of time. BUT
I have one problem.
The form has 2 sections. the first carries fields such as date, place etc, the second "sub form" contains several rows of fields, such as name etc. A row is completed per person attending an event. Each event could have 2, 3 or even up to 8 attending.
My problem is that at the moment I have 20 rows of data within the sub form. When we convert this to XML, the blank rows are also exported.
Is it possible to remove them at any point prior to exporting to XML?
 
Thanks
 

DeeperDownUK

My Product Information:
LiveCycle Designer, Windows
Bamboolian
Registered: Jul 27 2010
Posts: 48
Hi,

You can embed and use XSL transformation (XSLT) for input and output of XML.

for example pretend following is your background XML data.

<?xml version="1.0"?><DOC><HEAD><DATE>2010-09-01</DATE><PLACE>WALES</PLACE></HEAD><ITEMS><ITEM><PARTICIPANTS>JAMES</PARTICIPANTS></ITEM><ITEM><PARTICIPANTS /></ITEM></ITEMS></DOC>
In order not to output ITEM/PARTICIPANTS elements without value (in upper example it's second one), you can do so by embeding XSL transformation (XSLT) file like following to your connection property.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"><xsl:apply-templates /></xsl:template><xsl:template match="DOC"><DOC><xsl:copy-of select="HEAD"/><ITEMS><xsl:for-each select="ITEMS/ITEM"><xsl:if test="PARTICIPANTS!=''"><xsl:copy-of select="."/></xsl:if></xsl:for-each></ITEMS></DOC></xsl:template></xsl:stylesheet>
Good luck!