Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple XSLT files to single XSLT file for 2 different xml files
    primarykey
    data
    text
    <p>This is my xml file:</p> <pre><code>&lt;?xml version="1.0" encoding="windows-1250"?&gt; &lt;CONTACTS&gt; &lt;CONTACT&gt; &lt;FirstName&gt;Ford&lt;/FirstName&gt; &lt;LastName&gt;Pasteur&lt;/LastName&gt; &lt;EMail&gt;pasteur.ford@yahoo.com&lt;/EMail&gt; &lt;/CONTACT&gt; &lt;CONTACT&gt; &lt;FirstName&gt;Jack&lt;/FirstName&gt; &lt;LastName&gt;Sully&lt;/LastName&gt; &lt;URL&gt;http://www.facebook.com/profile.php?id=1000474277&lt;/URL&gt; &lt;/CONTACT&gt; &lt;CONTACT&gt; &lt;FirstName&gt;Colombo&lt;/FirstName&gt; &lt;LastName&gt;Chao&lt;/LastName&gt; &lt;EMail&gt;chao.colombo@liberto.it&lt;/EMail&gt; &lt;/CONTACT&gt; &lt;/CONTACTS&gt; </code></pre> <p>I used below XSLT file for my fist version of xml output.</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="xml" indent="yes"/&gt; &lt;xsl:strip-space elements="*"/&gt; &lt;xsl:template match="node()|@*"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="node()|@*"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="CONTACT"&gt; &lt;xsl:copy&gt; &lt;Customer-ID&gt; &lt;xsl:value-of select="generate-id(.)"/&gt; &lt;/Customer-ID&gt; &lt;xsl:copy-of select="FirstName|LastName|URL"/&gt; &lt;Facebook-ID&gt; &lt;xsl:choose&gt; &lt;xsl:when test="URL"&gt; &lt;xsl:value-of select="substring-after(URL,'?id=')"/&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/Facebook-ID&gt; &lt;EMAILS&gt; &lt;xsl:apply-templates select="EMail"/&gt; &lt;/EMAILS&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="EMail"&gt; &lt;EMail&gt; &lt;Type&gt;&lt;xsl:value-of select="substring-before( substring-after(.,'@'), '.')"/&gt; &lt;/Type&gt; &lt;Value&gt;&lt;xsl:value-of select="."/&gt;&lt;/Value&gt; &lt;/EMail&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>My first version of xml output from the above XSLT file:</p> <pre><code>&lt;?xml version="1.0" encoding="windows-1250"?&gt; &lt;CONTACTS&gt; &lt;CONTACT&gt; &lt;Customer-ID&gt;N65539&lt;/Customer-ID&gt; &lt;FirstName&gt;Ford&lt;/FirstName&gt; &lt;LastName&gt;Pasteur&lt;/LastName&gt; &lt;EMAILS&gt; &lt;EMail&gt; &lt;Type&gt;yahoo&lt;/Type&gt; &lt;Value&gt;pasteur.ford@yahoo.com&lt;/Value&gt; &lt;/EMail&gt; &lt;/EMAILS&gt; &lt;/CONTACT&gt; &lt;CONTACT&gt; &lt;Customer-ID&gt;N65546&lt;/Customer-ID&gt; &lt;FirstName&gt;Jack&lt;/FirstName&gt; &lt;LastName&gt;Sully&lt;/LastName&gt; &lt;URL&gt;http://www.facebook.com/profile.php?id=1000474277&lt;/URL&gt; &lt;Facebook-ID&gt;1000474277&lt;/Facebook-ID&gt; &lt;EMAILS/&gt; &lt;/CONTACT&gt; &lt;CONTACT&gt; &lt;Customer-ID&gt;N65553&lt;/Customer-ID&gt; &lt;FirstName&gt;Colombo&lt;/FirstName&gt; &lt;LastName&gt;Chao&lt;/LastName&gt; &lt;EMAILS&gt; &lt;EMail&gt; &lt;Type&gt;liberto&lt;/Type&gt; &lt;Value&gt;chao.colombo@liberto.it&lt;/Value&gt; &lt;/EMail&gt; &lt;/EMAILS&gt; &lt;/CONTACT&gt; &lt;/CONTACTS&gt; </code></pre> <p>This is my second XSLT file:</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="xml" indent="yes"/&gt; &lt;xsl:strip-space elements="*"/&gt; &lt;xsl:template match="node()|@*"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="node()|@*"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="CONTACT"&gt; &lt;xsl:copy&gt; &lt;Customer-ID&gt; &lt;xsl:value-of select="Customer-ID"/&gt; &lt;/Customer-ID&gt; &lt;FirstName&gt; &lt;xsl:value-of select="FirstName"/&gt; &lt;/FirstName&gt; &lt;LastName&gt; &lt;xsl:value-of select="LastName"/&gt; &lt;/LastName&gt; &lt;gmail&gt; &lt;xsl:value-of select="EMAILS/EMail[Type='gmail']/Value"/&gt; &lt;/gmail&gt; &lt;yahoo&gt; &lt;xsl:value-of select="EMAILS/EMail[Type='yahoo']/Value"/&gt; &lt;/yahoo&gt; &lt;liberto&gt; &lt;xsl:value-of select="EMAILS/EMail[Type='liberto']/Value"/&gt; &lt;/liberto&gt; &lt;URL&gt; &lt;xsl:value-of select="URL"/&gt; &lt;/URL&gt; &lt;Facebook-ID&gt; &lt;xsl:value-of select="Facebook-ID"/&gt; &lt;/Facebook-ID&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; </code></pre> <p></p> <p>This is my final xml output from the 2nd XSLT file:</p> <pre><code>&lt;?xml version="1.0" encoding="windows-1250"?&gt; &lt;CONTACTS&gt; &lt;CONTACT&gt; &lt;Customer-ID&gt;N65539&lt;/Customer-ID&gt; &lt;FirstName&gt;Ford&lt;/FirstName&gt; &lt;LastName&gt;Pasteur&lt;/LastName&gt; &lt;gmail/&gt; &lt;yahoo&gt;pasteur.ford@yahoo.com&lt;/yahoo&gt; &lt;liberto/&gt; &lt;URL/&gt; &lt;Facebook-ID/&gt; &lt;/CONTACT&gt; &lt;CONTACT&gt; &lt;Customer-ID&gt;N65546&lt;/Customer-ID&gt; &lt;FirstName&gt;Jack&lt;/FirstName&gt; &lt;LastName&gt;Sully&lt;/LastName&gt; &lt;gmail/&gt; &lt;yahoo/&gt; &lt;liberto/&gt; &lt;URL&gt;http://www.facebook.com/profile.php?id=1000474277&lt;/URL&gt; &lt;Facebook-ID&gt;1000474277&lt;/Facebook-ID&gt; &lt;/CONTACT&gt; &lt;CONTACT&gt; &lt;Customer-ID&gt;N65553&lt;/Customer-ID&gt; &lt;FirstName&gt;Colombo&lt;/FirstName&gt; &lt;LastName&gt;Chao&lt;/LastName&gt; &lt;gmail/&gt; &lt;yahoo/&gt; &lt;liberto&gt;chao.colombo@liberto.it&lt;/liberto&gt; &lt;URL/&gt; &lt;Facebook-ID/&gt; &lt;/CONTACT&gt; &lt;/CONTACTS&gt; </code></pre> <p>How do I merge these two XSLT files as a single XSLT file to get my final XML output.</p> <p>how do i proceed with this? because there are two different xml files of similar type.</p> <p>I'm using Eclipse Hellios run as -->XSL transformation to see the output.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload