Expand my Community achievements bar.

Prefixed XMLNS and exported XML from PDF

Avatar

Level 1

I have the following XSD sample:


<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.irs.gov/efile" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.irs.gov/efile" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0">

<xsd:annotation>
  <xsd:documentation>
  ..

  </xsd:documentation>


</xsd:annotation>

<xsd:include schemaLocation="efileTypes.xsd"/>


<!-- ===================================  ATTACHMENTS TO MESSAGES  =================================== -->


<!-- IRS Submission Manifest -->
<xsd:element name="IRSSubmissionManifest">
  <xsd:complexType>
   <xsd:sequence>

..

I am importing the XSD file into Designer and generating all possible fields. I include a button to generate XML output using Acrobat. When I load the PDF into Acrobat and generate the XML, I want the following result:

  <IRSSubmissionManifest xmlns="http://www.irs.gov/efile" xmlns:efile="http://www.irs.gov/efile">

However, no matter how I edit the XSD, I can only generate the following result:

<IRSSubmissionManifest xmlns="http://www.irs.gov/efile">

How do I get the " xmlns:efile="http://www.irs.gov/efile" " fragment to appear in the IRSSubmissionManifest element?


Thank you.

5 Replies

Avatar

Level 10

Hi, I would be surprised you could have a prefix for the target namespace I think you will either have to have <IRSSubmissionManifest xmlns="http://www.irs.gov/efile"> or <IRSSubmissionManifest xmlns:efile="http://www.irs.gov/efile"> but no both.

If you could explain why you need this then maybe someone can offer a work around.  There are a couple of transformation options available depending on your method of submission.  But can only imagine that you are allowing for some non-standard xml processing?

Regards

Bruce

Avatar

Level 1

Thank you for your response.

The namespace requirement is imposed by the IRS for e-flling tax returns. The file won't parse without it.

It seems that the easiest solution would be to make an XSLT to transform the element in the output XML. I haven't made such a file before so I don't know the correct syntax quite yet, but I am slowly figuring it out.

It seems like I need to do something resembling this in the XSLT file, but different:

<xsl:template match="IRSSubmissionManifest">

<IRSSubmissionManifest xmlns="http://www.irs.gov/efile" xmlns:efile="http://www.irs.gov/efile">

</IRSSubmissionManifest>

</xsl:template>

It's too bad that Designer doesn't seem to have a way to set or alter element attributes somewhere in the Data Connection tab (none that I've seen at least).

Avatar

Level 10

Hi, I'm rusty with XSLT but you will have to handle the namespace in your match so something like;

<xsl:stylesheet version="1.0" xmlns:efile="http://www.irs.gov/efile" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="efile:IRSSubmissionManifest">
  <IRSSubmissionManifest xmlns="
http://www.irs.gov/efile" xmlns:efile="http://www.irs.gov/efile">
   <xsl:for-each select="descendant::*">
    <xsl:copy-of select="."/>
   </xsl:for-each>
  </IRSSubmissionManifest>
</xsl:template>
</xsl:stylesheet>

I'm sure there must be a way of doing this without the for-each but this might help.

There is a preSubmit event but I woud expect it to be differcult to add a namespace prefix, if it didn't like it in the XSD.

Good luck

Bruce

Avatar

Level 1

Thanks again for your help.

I tested your code as-is on a webpage for testing XLST, and when I gave it some sample XML data it returned all the element content with the element tags removed. The sample data is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<IRSSubmissionManifest xmlns="http://www.irs.gov/efile"><SubmissionId>2</SubmissionId><EFIN>123456</EFIN><TaxYear>2011</TaxYear><GovernmentCode>IRS</GovernmentCode><FederalSubmissionType>1040</FederalSubmissionType><TaxPeriodBeginDate>20110101</TaxPeriodBeginDate><TaxPeriodEndDate>20111231</TaxPeriodEndDate><TIN>123456789</TIN></IRSSubmissionManifest>

I altered the fourth line of your XSLT to read as follows: <xsl:template match="IRSSubmissionManifest">

I tested that XSLT on this page: http://xslttest.appspot.com/

And the result was exatly what I needed.

However, I since imported that XSLT into the PDF in Designer and the transformation doesn't occur. The generated XML has all element tags removed. I receive no error messages regarding the XSLT when I save the PDF file in Designer.

So close yet not enough.

I wonder if the XML export functionality doesn't like having the root element tag altered. Regardless, it doesn't seem like any of the data supplied is in error.

Avatar

Level 10

Hi, I'm not sure what might be going wrong with the XSLT ... the test page does not load in my browser.  I did try XMLSpy, Visual Studio and the Designer Forms and it seems to work as I understand the problem.

This is the link to the Designer Form version I tried https://acrobat.com/#d=AD9RSFJ535-90IfCzzOcqA

Returning the element content with tags removed is the default behaviour if nothing matches the template, so there must be something going wrong with the match clause.

Regards

Bruce