Need to apply to only a specific node based on var
In short, I am trying to loop through one xml and use the info in that to apply xslt docs to an original xml.
Oringal Incoming XML:
<?xml version="1.0" encoding="UTF-8"?>
<Root DocumentType="01">
<EmployeeData>
<EmployeeUniqueIdentifier>1054</EmployeeUniqueIdentifier>
<FirstName>Donald</FirstName>
<LastName>Duck</LastName>
</EmployeeData>
<EmployeeData> <EmployeeUniqueIdentifier>9999</EmployeeUniqueIdentifier>
<FirstName>Daffy</FirstName>
<LastName>Duck</LastName>
</EmployeeData>
<EmployeeData>
<EmployeeUniqueIdentifier>9998</EmployeeUniqueIdentifier>
<FirstName>Mickey</FirstName>
<LastName>Mouse</LastName>
</EmployeeData>
</Root>
I first use this XSLT to create a metadata XML document:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:param name="Employees">
<xsl:value-of select="count(//EmployeeData)"/>
</xsl:param>
<xsl:template match="/">
<xsl:for-each select="//EmployeeData">
<__service __serviceType="EmployeeMaint">
<xpath>//Employee(<xsl:number value="position()" format="1"/>)</xpath>
<xslt>Single_EmpMaint.xslt</xslt>
</__service>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Applied to the original XML outputs(to a memory string variable):
<?xml version="1.0" encoding="UTF-8"?>
<__service __serviceType="EmployeeMaint">
<xpath>//Employee(1)</xpath>
<xslt>Single_EmpMaint.xslt</xslt>
</__service>
<__service __serviceType="EmployeeMaint">
<xpath>//Employee(2)</xpath>
<xslt>Single_EmpMaint.xslt</xslt>
</__service>
<__service __serviceType="EmployeeMaint">
<xpath>//Employee(3)</xpath>
<xslt>Single_EmpMaint.xslt</xslt>
</__service>
I am looping through this xml string (using .Net)
And for each "serviceType", I want to apply the style sheet in the <xslt/> to an original XML Doc but have it apply to only the node specified.
Single_EmpMain.xslt Stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-16LE" indent="yes"/>
<xsl:template match="/">
<__InSite __version="1.1">
<__service __serviceType="EmployeeMaint">
<__perform>
<__eventName>BscSetAction</__eventName>
</__perform>
<__inputData>
<ObjectChanges>
<Name>
<xsl:value-of select="FirstName"/>
</Name>
<LastName>
<xsl:value-of select="LastName" />
</LastName>
<Description>Test</Description>
</ObjectChanges>
</__inputData>
<__execute/>
<__requestData>
<CompletionMsg/>
</__requestData>
</__service>
</__InSite>
</xsl:template>
</xsl:stylesheet>
I believe somehow I should have a parameter in the second stylesheet that 'looks up' the node specified in the service_type xml doc, but not sure how to do this? I've been researching with-param's and params, but nothing is quite like this.. I don't have to stick to this format, it's just what I am given to work with. The .Net application though is looping through the nodes of the service type and my challenge is to get it to apply the xsly style sheet to the correct node, one at a time. It then is spitting out a seperate file for each employee. (XSLT 2.0) isn't an option here.
I heard there was a way to get XSLT 1.0 to split out different files, but haven't found it. I am not sure which way is the best here.
Any help or ideas would be greatly appreciated!
Thanks!
:D
Russ
Thanks!
Russell H. Fleming, Jr.
|