Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 7th, 2013, 01:27 PM
Registered User
 
Join Date: Aug 2013
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default xml flat file transform to nested tag xml using xslt transform

i have a requirement to change flat xml file to nested xml file using xslt and xml template input.
my input xml file demo.xml is
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><ns1:getDocumentByKeyRespo nse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://www.taleo.com/ws/integration/toolkit/2005/07"><Document xmlns="http://www.taleo.com/ws/integration/toolkit/2005/07"><Attributes><Attribute name="duration">0:00:00.130</Attribute><Attribute name="count">7</Attribute><Attribute name="entity">Requisition</Attribute><Attribute name="mode">XML</Attribute><Attribute name="version">http://www.taleo.com/ws/tee800/2009/01</Attribute></Attributes><Content>
<ExportXML xmlns="http://www.taleo.com/ws/integration/toolkit/2005/07">
<record>
<field name="ContestNumber">1300000F</field>
<field name="ManagerRequisitionTitle">Project Manager</field>
</record>
<record>
<field name="ContestNumber">1300000H</field>
<field name="ManagerRequisitionTitle">Project Manager</field>
</record>
<record>
<field name="ContestNumber">1300000T</field>
<field name="ManagerRequisitionTitle">Project Manager</field>
</record>
<record>
<field name="ContestNumber">13000018</field>
<field name="ManagerRequisitionTitle">Project Manager</field>
</record>
<record>
<field name="ContestNumber">000123</field>
<field name="ManagerRequisitionTitle">Project Manager</field>
</record>
<record>
<field name="ContestNumber">1300000R</field>
<field name="ManagerRequisitionTitle">Project Manager</field>
</record>
<record>
<field name="ContestNumber">13000016</field>
<field name="ManagerRequisitionTitle">Project Manager</field>
</record>
</ExportXML></Content></Document></ns1:getDocumentByKeyResponse></soapenv:Body></soapenv:Envelope>

my xslt file mycustom.xsl is

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:itk="http://www.taleo.com/ws/integration/toolkit/2005/07">
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="itk:record">
<xsl:text>INSERT EMPLOYEE:</xsl:text>
<xsl:value-of select="itk:field[@name='FirstName']"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="itk:field[@name='MiddleInitial']"/>
<xsl:text>|</xsl:text>
<xsl:value-of select="itk:field[@name='LastName']"/>
<xsl:text disable-output-escaping="yes"> </xsl:text>
<xsl:text>E-MAIL:</xsl:text>
<xsl:value-of select="itk:field[@name='EmailAddress']"/>
<xsl:text disable-output-escaping="yes"> </xsl:text>
<xsl:text>STREET ADDRESS:</xsl:text>
<xsl:value-of select="itk:field[@name='Address']"/>
<xsl:text>;</xsl:text>
<xsl:text>CITY:</xsl:text>
<xsl:value-of select="itk:field[@name='City']"/>
<xsl:text>;</xsl:text>
<xsl:text>STATE:</xsl:text>
<xsl:value-of select="itk:field[@name='State']"/>
<xsl:text>;</xsl:text>
<xsl:text>ZIPCODE:</xsl:text>
<xsl:value-of select="itk:field[@name='ZipCode']"/>
<xsl:text>;</xsl:text>
<xsl:text disable-output-escaping="yes"> </xsl:text>
<xsl:text>====</xsl:text>
<xsl:text disable-output-escaping="yes"> </xsl:text>
</xsl:template>
</xsl:stylesheet>

the main problem is it is asking the input template xml file with main record placeholder.sorry really i am new to xml.
my expected output is output.xml
<?xml version="1.0" encoding="UTF-8" ?>
<JobPositionPostings>
<JobPositionPosting>
<JobPositionPostingID>1300000F</JobPositionPostingID>
<Industry>
<jobPost>Project Manager</jobPost>
</Industry>
</JobPositionPosting>
</JobPositionPostings>

please tell me what is my input xml template as i read it contain xsl file path and record placeholder. template.xml
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="mycustom.xsl"?>
please how to write placeholder after this.
thanks in advance





Similar Threads
Thread Thread Starter Forum Replies Last Post
Transform xml to xml changing one tag. surfer97301 XSLT 2 April 21st, 2010 05:14 PM
transform tag attributes into xml tags guitarzan8 XSLT 1 April 21st, 2010 02:56 PM
Split xml file with result document and javax.xml.transform.Transformer. nisargmca XSLT 3 January 12th, 2010 06:26 AM
How do I transform XSLT without the <?xml?> tag? nadavvin XSLT 4 June 10th, 2007 09:25 AM
XSLT read through XML to transform another XML dendenx2 XSLT 8 July 7th, 2005 08:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.