| Simple XSLT Assistance Very new to XSLT looking for some assistance |
cvgordy

msg:4408367 | 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> OR <?xml version="1.0" encoding="UTF-8"?> -<Batch BatchName="20120118.132405" BatchID="107"> -<Document DocumentType="XSLT Sample Migration"> -<Fields> <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"/> </Fields> -<Files> <File>D:\Migration\00000001.tif</File></Files></Document> </Batch> The first output I'm attempting to replicate is: <?xml version="1.0" standalone="yes"?> <KofaxRelease> <kofax> <doc_id>13345</doc_id> <vendor_code>VNF</vendor_code> <property_code>PNFProperty Not Found</property_code> <invoice_num /> <invoice_amount>91.3500</invoice_amount> <invoice_date>04/12/2011</invoice_date> <remittance_adv>No</remittance_adv> <exception>Yes</exception> <exception_reason>NO NSX#</exception_reason> <batch_id>68315</batch_id> <date_converted>2011-04-20T17:30:04.333-04:00</date_converted> <date_created>2011-04-20T00:00:00-04:00</date_created> <doc_path>\\qaweb\Kofax Data\CLIENT\Images\00146B85.pdf</doc_path> </kofax> 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.
|
Dijkgraaf

msg:4408421 | 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> <xsl:template match="/Batch"> <KofaxRelease> <kofax> <xsl:for-each select="Document/Fields/Field"> <xsl:if test="@FieldName = 'Doc_ID'"> <doc_id> <xsl:value-of select="./text()" /> </doc_id> </xsl:if> </xsl:for-each> <batch_id> <xsl:value-of select="@BatchID" /> </batch_id> </kofax> </KofaxRelease> </xsl:template> </xsl:stylesheet>
|
cvgordy

msg:4408447 | 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!
|
|
|