homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / XML Development
Forum Library, Charter, Moderators: httpwebwitch

XML Development Forum

Simple XSLT Assistance
Very new to XSLT looking for some assistance

Msg#: 4408365 posted 10:09 pm on Jan 18, 2012 (gmt 0)

I've recently been assigned the task of converting some of our standard XML output to custom formats and I would love some assistance if anyone can provide it!

I have two differen output options I can work from:

<?xml version="1.0" encoding="UTF-8"?>
-<batch BatchName="20120118.132647">
-<document Doc_path="" Date_created="" Date_converted="" Batch_id="" Exception_reason="" Exception="" Remittance_adv="" Invoice_date="" Invoice_amount="" Invoice_num="" Property_code="" Vendor_code="" Doc_ID="">
-<files><file path="D:\Migration\00000001.tif"/></files></document></batch>


<?xml version="1.0" encoding="UTF-8"?>
-<Batch BatchName="20120118.132405" BatchID="107">
-<Document DocumentType="XSLT Sample Migration">
<Field FieldName="Doc_ID"/>
<Field FieldName="Vendor_code"/>
<Field FieldName="Property_code"/>
<Field FieldName="Invoice_num"/>
<Field FieldName="Invoice_amount"/>
<Field FieldName="Invoice_date"/>
<Field FieldName="Remittance_adv"/>
<Field FieldName="Exception"/>
<Field FieldName="Exception_reason"/>
<Field FieldName="Batch_id"/>
<Field FieldName="Date_converted"/>
<Field FieldName="Date_created"/><Field FieldName="Doc_path"/>

The first output I'm attempting to replicate is:

<?xml version="1.0" standalone="yes"?>
<property_code>PNFProperty Not Found</property_code>
<invoice_num />
<exception_reason>NO NSX#</exception_reason>
<doc_path>\\qaweb\Kofax Data\CLIENT\Images\00146B85.pdf</doc_path>

I've managed to generate an XSLT that produces the same exact output as the input, however as soon as I try to start modifying the output things break in a bad way.



WebmasterWorld Senior Member 5+ Year Member

Msg#: 4408365 posted 2:05 am on Jan 19, 2012 (gmt 0)

Maybe this will get you started. This is for the second example.

<?xml version="1.0" encoding="utf-16" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
<xsl:template match="/">
<xsl:apply-templates select="/Batch" />
<xsl:template match="/Batch">
<xsl:for-each select="Document/Fields/Field">
<xsl:if test="@FieldName = 'Doc_ID'">
<xsl:value-of select="./text()" />
<xsl:value-of select="@BatchID" />


Msg#: 4408365 posted 6:07 am on Jan 19, 2012 (gmt 0)

Thanks for the reply. I will give this a try and see how far I can get!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / XML Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved