xslt - How to make hidden filed dynamically using xml -
i have xml out , based on want creat input hidden filed dynamically. suppose have below xml output
<?xml version="1.0"?> <mb> <rq> <flddeviceid><![cdata[iyh4knneu6gdcl4qcqmbzil2woi=]]></flddeviceid> <uid><![cdata[fdsfs]]></uid> <account><![cdata[fsdfds]]></account> <operatortype><![cdata[m]]></operatortype> <mobile><![cdata[9029938117]]></mobile> <user-agent><![cdata[windowsphone]]></user-agent> <sessionkey><![cdata[83727d34-bfef-45ca-955b-4695d035cd98]]></sessionkey> <account_txt><![cdata[fsafsa- chandivali, mumbai]]></account_txt> <amount><![cdata[10]]></amount> <requesttype><![cdata[icpmr]]></requesttype> <operationid><![cdata[dfs]]></operationid> <operator_txt><![cdata[aircel]]></operator_txt> <fldlangid><![cdata[en-us]]></fldlangid> <operator><![cdata[arc]]></operator> <transseq><![cdata[03]]></transseq> </rq> <rs> <cardno>#5435345</cardno> <authchar1>b</authchar1> <authchar2>h</authchar2> <authchar3>o</authchar3> </rs> </mb>
in there may thousand of tags , want in input hidden filed given below in xslt transformation.
<input type="hidden" id="{flddeviceid}" value="flddeviceid" /> <input type="hidden" id="{uid}" value="uid" />
and on...i don't want write thousand of line. how me out.
it not clear records in xml want "hidden", assuming 1 ones under rq, define template so
<xsl:template match="rq/*"> <input type="hidden" id="{.}" value="{local-name()}" /> </xsl:template>
try xslt example
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform" version="2.0"> <xsl:output indent="yes"/> <xsl:template match="/"> <xsl:apply-templates select="rq/*" /> </xsl:template> <xsl:template match="rq/*"> <input type="hidden" id="{.}" value="{local-name()}" /> </xsl:template> </xsl:stylesheet>
Comments
Post a Comment