Expand my Community achievements bar.

SOLVED

Splitting XML with Transform

Avatar

Former Community Member

I am working on an application to create Work Orders using output. The host application sends a batch of Work Orders in XML format (generated using JFTRANS from the Central Migration). The XML contains the customer number. I use Transform to sort the incoming XML by customer number.The structure of the XML is like this:

<File>

     <Record>

         <Header>

               <custno>1234</custno>

               <wonumber>001234<.wonumber>

               <page>1</page

               .

               .

          </Header>

          <Detail>

               <lineno>1</lineno>

               <itemno>004444</itemno>

               .

               .

          </Detail>

          <Detail>

               <lineno>2</lineno>

               <itemno>005555</itemno>

               .

               .

          </Detail>

          <Header>

               .

          </Header>

          <Detail>

               .

          </Detail>

     </Record>

     <Record>

          .

     </Record>

</File>

I tried to use the "Generate Multiple Streams" option of Output/generatePDFOutput to split the output by customer. Unfortunately, the "Generate Multiple Streams" only offers splitting on a "Record" level, not based on content. I need to generate a separate output file for each customer, which could have multiple Work Orders, each with 1 - n pages.

The Foundation/Transform activity doesn't seem to have the functionality to define an XML split via XSLT.

Has anyone done this before?

Thank you!

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

You're welcome Alex.

Since this is a recurring request on the forum I put together the attached PDF. The PDF describes a technique for splitting an XML document using the XSLT service and includes the following attachments: an ES2 .lca, a sample XML document and the XSL included in the process.

If you have any questions or comments please email stwalker.adobe@gmail.com.

Thanks,

Steve

View solution in original post

6 Replies

Avatar

Former Community Member

Different XSLT processors, including those that are XSLT 2.0 and Saxon 9 compliant, can split one XML document and write multiple XML documents. While the XSLT Transform operation uses Saxon (I am not sure which version) the DSC is not designed to output multiple results AFAIK.

You would have to use an external process or a custom script to do the split and writes.

Steve

Avatar

Former Community Member

Does each Record node contain a complete document? If so then you should be able to tell Output to create new docs on each Record node.

Paul

Avatar

Former Community Member

Thank you Steve. That's what I expected. I "bit the bullet" and wrote my own XML splitter to (a) split the XML and (b) pass a list of the resulting XML files back to the process. It would be nice if LC ES2.5 would let us do the split with the Transform / XSLT Service. 

Avatar

Former Community Member

Thank you Paul, unfortunately I can't use the "Generate Multiple Streams" option. The <Record> level could be a new transaction or a "Page n of m" and I need to split on a transaction level. 

Avatar

Correct answer by
Former Community Member

You're welcome Alex.

Since this is a recurring request on the forum I put together the attached PDF. The PDF describes a technique for splitting an XML document using the XSLT service and includes the following attachments: an ES2 .lca, a sample XML document and the XSL included in the process.

If you have any questions or comments please email stwalker.adobe@gmail.com.

Thanks,

Steve

Avatar

Former Community Member

Hello Steve,

Thank you very much for this very helpful example and your thorough explanations.

I really appreciate it!

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----