[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Child Nodes Problem
Yes David I have tried before <xsl:for-each select="//Product">. Still I am missing <ProdIDT> <IDV> header and output also coming wrong. Both tag value is close. Output should be come ProdIDT IDV ProdIDT IDV 02 1616200243 03 9781616200244 Please advise.. Thanks Byomokesh On Thu, Jun 3, 2010 at 4:31 PM, David Carlisle <davidc@xxxxxxxxx> wrote: > On 03/06/2010 11:46, Byomokesh Sahoo wrote: > >> >> <xsl:variable name="delimiter" select="'	'"/> >> <xsl:variable name="fieldNames" select="'yes'"/> >> >> <xsl:template match="/"> >> >> <xsl:for-each select="//Product/child::*|//Product/self::*"> > > That is the same as //Product/(.|*) although do you really need to search > the entire document with // for product, or is it always at the top of your > file. Your code below does for-each starting from here so it appears to be > expecting to llop over the children of product, so i suspect this line > should be > <xsl:for-each select="//Product"> > > >> >> <xsl:if test="$fieldNames = 'yes'"> >> >> <xsl:if test="position() = 1 or position()>1"> > > this test is always true as position() is always an integer greater than > zero, for all documents. >> >> <xsl:for-each select="@*"> >> <xsl:value-of select="name()"/> > > this would list the names of the attributes (in an arbitrary order) but your > sample input has no attributes >> >> <xsl:value-of select="$delimiter"/> >> >> </xsl:for-each> >> >> <xsl:for-each select="*"> >> <xsl:value-of select="name()"/> >> >> <xsl:if test="position() != last()"> >> <xsl:value-of select="$delimiter"/> >> </xsl:if> >> </xsl:for-each> >> <xsl:text> >> </xsl:text> > > here you prpbably just want <xsl:text> </xsl:text> > to insert a newline rather than a newline and some indentation space copied > from the stylesheet. >> >> </xsl:if> >> </xsl:if> >> <xsl:for-each select="@*"> >> <xsl:value-of select="."/> >> <xsl:value-of select="$delimiter"/> >> </xsl:for-each> > > again this would list any attributes if you had them. >> >> <xsl:for-each select="*"> >> <xsl:value-of select="."/> >> <xsl:if test="position() != last()"> >> <xsl:value-of select="$delimiter"/> >> </xsl:if> >> </xsl:for-each> > > The above for-each (which was the xslt 1 way) can be more simply > written as > <xsl:value-of select="*" separator="$delimiter"/> > >> <xsl:text> >> </xsl:text> > > again just use ,xsl:text> </xsl:text> if you want to insert just a new > line and no spaces. >> >> </xsl:for-each> >> </xsl:template> >> > David > > ________________________________________________________________________ > The Numerical Algorithms Group Ltd is a company registered in England > and Wales with company number 1249803. The registered office is: > Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. > > This e-mail has been scanned for all viruses by Star. The service is > powered by MessageLabs. > ________________________________________________________________________
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|