on 09-03-2013 7:15 AM
Hi,
I have never done XSLT. So experts need your help.
Interface is related to HR - Job Application Data
My Source and Target XML is in Screenshot : -
also i have uploaded the source and target XML for your reference as attachment .
Kindly help me in writting XSLT or if any one can provide me XSLT for this .
I now this can be easily solve with Java Mapping or even with graphical node functions but i need XSLT only.
Regards
Prabhat Sharma
Here is a quick guide to basic XSLT Tags for your reference....It will be helpful in writing XSLT mapping.
I use Stylus Studio in my project for doing XSLT related stuff....its very useful and have lots of options for mapping. Just feed your source and target structure and do the graphical mapping as per your requirement.
Its available for free with a 15 days trial.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I agree with you Sumit, we are using Oxygen here. Also a good resource for questions on XSLT is: http://www.stackoverflow.com
Best regards,
Peter
Hello Prabhat Sharma,
You could also work with keys and do a so called "hierarchical grouping" on your source XML(your source and your target are not valid by the way. I attached corrected versions):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:key name="fNamelName" match="Application" use="concat(FName,'|',LName)"/>
<!-- define which elements are unique -->
<xsl:template match="Header">
<xsl:variable name="uniqueTransactions" select="Application[generate-id()=generate-id(key('fNamelName',concat(FName,'|',LName))[1])]"/>
<Header>
<xsl:apply-templates select="$uniqueTransactions" mode="group"/>
</Header>
</xsl:template>
<!-- create the unique groups -->
<xsl:template match="Application" mode="group">
<Application>
<xsl:copy-of select="FName"/>
<xsl:copy-of select="LName"/>
<xsl:copy-of select="CID"/>
<JoiningLocation>
<xsl:apply-templates select="key('fNamelName', concat(FName,'|',LName))" mode="item"/>
</JoiningLocation>
</Application>
</xsl:template>
<!-- write the item content into each group; this template is called by the two templates before -->
<xsl:template match="Application" mode="item">
<xsl:copy-of select="child::JoiningPreferedCity"/>
</xsl:template>
</xsl:stylesheet>
Best regards,
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Depending upon the first and last name pairs i am splitting the records, so if u want u can enhance below XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://MappingTechnique">
<xsl:template match="/">
<MT>
<xsl:for-each select="//Application">
<xsl:sort select="concat(FName,LName)"/>
<xsl:if test="not(FName = preceding-sibling::Application/FName and LName = preceding-sibling::Application/LName )">
<Application>
<FName>
<xsl:value-of select="FName"/>
</FName>
<LName>
<xsl:value-of select="LName"/>
</LName>
<persons>
<xsl:call-template name="process_items">
<xsl:with-param name="items" select="concat(FName,LName)"/>
</xsl:call-template>
</persons>
</Application>
</xsl:if>
</xsl:for-each>
</MT>
</xsl:template>
<xsl:template name="process_items">
<xsl:param name="items"/>
<xsl:for-each select="//Application">
<xsl:if test="($items = concat(FName,LName))">
<person>
<xsl:value-of select="JoiningPreferedCity"/>
</person>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Thanks
Amit Srivastava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
have a look at the following commands
<xsl:template match="xPath to the location in your XML, where your key (probably CID) resides">
<xsl:variable name="yourVariable" select="xPath to your preffered key (probably CID)"/>
<xsl:apply-templates select="xPath to the location in your XML, where your key (probably CID) resides[keyname = $yourVariable"/>
HTH
Cheers
Jens
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I wonder why you need XSLT if
this can be easily solve with Java Mapping or even with graphical node functions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.