Re: [xsl] Unwanted Empty Elements from transformation

Subject: Re: [xsl] Unwanted Empty Elements from transformation
From: Jarkko.Moilanen@xxxxxx
Date: Fri, 05 Jul 2002 07:34:48 +0300 (EEST)
Lainaus Joerg Heinicke <joerg.heinicke@xxxxxx>:

> Hello,
> 
> you have a few Foundation.Core.Class elements in your XMI (?) file, that

OMG XML Metadata Interchance (XMI). 
www.omg.org

> 
> don't have Foundation.Core.ModelElement.name elements as childs, so the 
> <xsl:value-of select="Foundation.Core.ModelElement.name"/> returns an 
> empty string.
> 
> You can either change you <xsl:apply-templates/> to
> 
> <xsl:apply-templates 
> select="//Foundation.Core.Class[Foundation.Core.ModelElement.name]"/>
> 
> or add a predicate to the template matcher
> 
> <xsl:template 
> match="Foundation.Core.Class[Foundation.Core.ModelElement.name]">
> 
> Regards,
> 
> Joerg
> 
> 
> Raheem Rufai wrote:
> > Hello Everyone,
> > 
> > I've got a problem with my stylesheet. Here it is:
> > 
> > <?xml version="1.0" encoding="iso-8859-1"?>
> > <xsl:stylesheet 
> >   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> >   version="1.0"
> > 
> > <xsl:output method="xml" indent="yes" encoding = 'ISO-8859-1' />
> > 
> > <xsl:template match="/">
> >     <start>
> >        <xsl:apply-templates select="//Foundation.Core.Class" />
> >     </start>
> > </xsl:template>
> > <xsl:template match="Foundation.Core.Class">
> >   <class>
> >    <xsl:value-of select="Foundation.Core.ModelElement.name" />    
> >   </class>
> > </xsl:template>
> > <xsl:template match="*" />
> > </xsl:stylesheet>
> > 
> > While the template outputs the values expected of it, it also outputs
> some
> > annoying empty <class> elements. Here is a sample output:
> > 
> >   <?xml version="1.0" encoding="ISO-8859-1" ?> 
> > - <start>
> >    ....
> >   <class /> 
> >   <class>ApplicantFile</class> 
> >   <class /> 
> >   <class /> 
> >   <class /> 
> >   <class /> 
> >   <class>ApplicationDoc</class> 
> >   <class /> 
> >   <class /> 
> >   <class /> 
> >   <class /> 
> >   <class>ApplicationForm</class> 
> >   <class /> 
> >   <class /> 
> >   <class /> 
> >   <class /> 
> >   <class>DegreeRequirement</class> 
> >   <class>Department</class> 
> >   <class /> 
> >   <class /> 
> >   <class>EducationRecord</class> 
> >   <class>EvaluationForm</class> 
> >   <class>Major</class> 
> >   <class /> 
> >   <class /> 
> >   <class>RecommendationLetter</class> 
> >   <class>StandardizedTest</class> 
> >   <class>User</class> 
> >   <class><DummyClass></class> 
> >   </start>
> > 
> > Please, somebody help me out. I'm completely clueless, what the reason
> for
> > this behaviour is. I've tried the code on both saxon and xalan.
> > 
> > Thanks,
> > 
> > Raimi Rufai
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 



******************************************************************
Jarkko Moilanen         *You are wise, witty, and wonderful,     *
Researcher/ ITCM        *but you spend too much time             *
jm60697@xxxxxx          *reading this sort of trash.             *
www.uta.fi/~jm60697     *                                        *
GSM: +358 50 3766 927   *                                        *
******************************************************************
* ITCM | Information Technology and Crisis Management            *
* http://www.itcm.org                                            *
******************************************************************

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread