im trying build xml parameters, named as:
p_nodes: contain data (string separated comas) of nodes xml
p_data: contain data (string separated comas) of going inside node.
so far got this:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:param name="p_nodes"/> <xsl:param name="p_data"/> <xsl:template match="/"> <xsl:for-each select="tokenize($p_nodes,',')"> <xsl:variable name="elemname" select="normalize-space(.)"/> <xsl:variable name="pos" select="position()"/> <xsl:element name="{$elemname}"> <xsl:value-of select="tokenize($p_data,',')[position()=$pos]"/> </xsl:element> </xsl:for-each> </xsl:template> </xsl:stylesheet>
applying parameters:
p_nodes: number,address,name,numdoc
p_data: 123,principal av,alberto,456
the output got this:
<?xml version="1.0" encoding="utf-8"?> <number>123</number> <address>principal av</address> <name>alberto</name> <numdoc>456</numdoc>
so working fine, @ point.
what i'm trying achive tranformation using upper cases identified parent nodes this:
p_nodes: document,header,number,address,name,numdoc,/header,detail,description,/detail,/document
p_data: 123,principal av,alberto,456,example description
output xml
<?xml version="1.0" encoding="utf-8"?> <document> <header> <number>123</number> <address>principal av</address> <name>alberto</name> <numdoc>456</numdoc> </header> <detail> <description>example</description> </detail> </document>
please let me know if i'm not being totally clear question.
thanks in advance guys!
-keva
Comments
Post a Comment