I would like to automate the elements based on input file expression.
My input file looks like
<?xml version="1.0" encoding="UTF-8"?>
<mappings>
<mapping inputContext="InputRoot" outputContext="outputRoot">
<input>InputParent/InputChild/InputSubChild</input>
<output>OutputParent/OPChild</output>
</mapping>
</mappings>
Based on above XML I had created the below XSLT
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns="http://www.testmapping.org/mapping">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="outputCtxt" select="mappings/mapping/output"/>
<xsl:call-template name="contextGenerator">
<xsl:with-param name="contextPath" select="$outputCtxt"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="contextGenerator">
<xsl:param name="contextPath" as="xs:string?"/>
<xsl:variable name="currentContext" select="substring-before($contextPath,'/')"/>
<xsl:variable name="subContext" select="substring-after($contextPath,'/')"/>
<xsl:element name="{$currentContext}">
<xsl:call-template name="contextGenerator">
<xsl:with-param name="contextPath" select="$subContext"/>
</xsl:call-template>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
I am expecting the output with below format
<outputRoot>
<OutputParent>
<OPChild></OPChild>
</OutputParent>
</outputRoot>
when I am trying to transform based on the input i am ending up with Expected QName error. Can I have the suggestions to address this issue.