Subject: RE: [xsl] Newbie Question: Creating Error Description from Invalid Input From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Fri, 13 Oct 2006 15:46:25 +0100 |
It would be more useful to tell us what you tried, then we could see where you went wrong. But you can do it like this: <xsl:template match="header"> <xsl:copy-of select="*[child::node()]" <xsl:if test="*[not(child::node()]"> <errorDescription> <xsl:text>Invalid elements:</xsl:text> <xsl:value-of select="*[not(child::node())]/name()" separator=", "/> </errorDescription> </xsl:if> </xsl:template> That's XSLT 2.0. If you're using 1.0, change the value-of line to <xsl:for-each select="*[not(child::node())]"> <xsl:value-of select="name()"/> <xsl:if test="position()!=last()">, </xsl:if> </xsl:for-each> Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Badari [mailto:badbadri@xxxxxxxxx] > Sent: 13 October 2006 15:21 > To: XSL List > Subject: [xsl] Newbie Question: Creating Error Description > from Invalid Input > > I am a newbie to XSL and am hoping that somebody can help me > with the following scenario. I tried to use xsl:variable but > was not successful. :( > > I have an "errorDescription" element in the target structure. > Depending on the error condition result on input fields, I > have to concatenate the field names (that are in error) and > post them to the errorDescription field. > > How can I do it? Any help is appreciated. > > sample input. > > <request> > <header> > <address1>1234</address1> > <address2></address2> > <address3>3456</address3> > <address4></address4> > </header> > </request> > > If all address elements are expected to have values, and 2nd > and 4th don't have values the output file should look like: > > <response> > <header> > <address1>1234</address1> > <address3>3456</address3> > <errorDescription>Invalid Elements: > Address2,Address4</errorDescription > </header> > </response> > > Thanks in advance for your help. > > Badari
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Newbie Question: Creating, Wendell Piez | Thread | Re: [xsl] Newbie Question: Creating, Richard Lewis |
Re: [xsl] Newbie Question: Creating, Richard Lewis | Date | Re: [xsl] short and long empty xml , Abel Braaksma |
Month |