Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

xslt, how to 'flatten' the tag structure for unknown number of child tags -


my source file looks this:

<x> <names>          <name>name1</name>          <name>name2</name> </names> <codes>          <code>code1</code>          <code>code2</code> </codes> <stuff> stuff </stuff> </x> 

and i'd transform output:

<out> <y>     <name>name1</name>     <code>code1</code>     <stuff> stuff </stuff> </y> <y>     <name>name2</name>     <code>code2</code>     <stuff> stuff </stuff> </y> </out> 

i don't know number of name , code tags in source file, know numer of names equals number of codes.

please share tips, how it.

this transformation:

<xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/xsl/transform">  <xsl:output omit-xml-declaration="yes" indent="yes"/>   <xsl:template match="/*">   <out>    <xsl:apply-templates select="names/name"/>   </out>  </xsl:template>   <xsl:template match="name">   <xsl:variable name="vpos" select="position()"/>   <y>    <xsl:copy-of select="."/>    <xsl:copy-of select=      "../../codes/code[position()=$vpos]"/>    <xsl:copy-of select="/*/stuff"/>   </y>  </xsl:template> </xsl:stylesheet> 

when applied on provided xml document:

<x>     <names>         <name>name1</name>         <name>name2</name>     </names>     <codes>         <code>code1</code>         <code>code2</code>     </codes>     <stuff> stuff </stuff> </x> 

produces wanted, correct result:

<out>    <y>       <name>name1</name>       <code>code1</code>       <stuff> stuff </stuff>    </y>    <y>       <name>name2</name>       <code>code2</code>       <stuff> stuff </stuff>    </y> </out> 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -