Append xml param input to root node of target xml



I have the source xml file as



<?xml version="1.0" encoding="UTF-8"?>
<ns0:entry xmlns:ns0="http://ift.tt/r5ut6F">
<ns0:content type="application/xml">
<ns0:properties>
<ns0:x>qwerty</ns0:x>
<ns0:y>OREQ</ns0:y>
<ns0:y>abc</ns0:y>
</ns0:properties>
</ns0:content>


And my xslt file looks as below



<xsl:stylesheet xmlns:xsl="http://ift.tt/tCZ8VR" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:param name="documentXML" />
<xsl:variable name="temp" select="document('documentXML')"/>
<xsl:variable name="tempLink" select="$temp/entry"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* , node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="entry">
<xsl:copy>
<xsl:apply-templates select="$tempLink" />
</xsl:copy>
</xsl:template>

</xsl:stylesheet>


The parameter above documentXML is passed as



<?xml version="1.0" encoding="UTF-8"?>
<ns0:entry xmlns:ns0="http://ift.tt/r5ut6F">
<ns0:link href="GetArtefactDetailsSet(ArtefactId)/EScHeaderSet" rel="http://ift.tt/1zpiEkw" title="application/atom+xml;type=feed" type="EScHeaderSet">
<ns0:inline>
<ns0:feed/>
</ns0:inline>
</ns0:link>
</ns0:entry>


Note that all this process is being run in tibco and the isXMLDocument flag for documentXML parameter is true()


I am getting below error when running it The [javax.xml.transform.TransformerException] occurred during XSLT transformation: javax.xml.transform.TransformerException: com.tibco.xml.xquery.ExprException: java.lang.NullPointerException


Also when i tried to just copy the document(paramValue) in the target xml it returned MalformedURLException : no protocol.


I have been stuck in this for few days need to get this done desperately. The resultant xml should be like this



<?xml version="1.0" encoding="UTF-8"?>
<ns0:entry xmlns:ns0="http://ift.tt/r5ut6F">
<ns0:link href="GetArtefactDetailsSet(ArtefactId)/EScHeaderSet" rel="http://ift.tt/1zpiEkw" title="application/atom+xml;type=feed" type="EScHeaderSet">
<ns0:inline>
<ns0:feed/>
</ns0:inline>
</ns0:link>
<ns0:content type="application/xml">
<ns0:properties>
<ns0:x>qwerty</ns0:x>
<ns0:y>OREQ</ns0:y>
<ns0:z>abc</ns0:z>
</ns0:properties>
</ns0:content>
</ns0:entry>

No comments:

Post a Comment