Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Coverting the Elements to Attributes, of the an XML file - giving another XML file [Thread Next] Re: Coverting the Elements to Attributes, of the an XML file - giving another XML fileTo: NULL Date: 7/7/2006 1:55:00 PM
abrahamregisraj@g... wrote:
> 1. if the newly formed element has all the attributes as blanks (""),
> then that should not be present.
That is a bit difficult with the current design of the stylesheet as you
can't add elements and attributes to the result tree and later check
them to remove them.
So you need a further check, either in the pattern or with an xsl:if e.g.
<xsl:template match="*[starts-with(local-name(), 'level')]">
<xsl:if test="normalize-space(name) != '' or
normalize-space(description) != ''">
<xsl:copy>
<xsl:apply-templates select="name | description"
mode="element-to-attribute" />
<xsl:apply-templates select="*[not(self::name) and
not(self::description)]" />
</xsl:copy>
</xsl:if>
</xsl:template>
> 2. The elements that do not start with "level" should not be present in
> the output XML file.
Well you had a root element named myxml, it is usually not possible to
remove that as it contains several child elements.
And your original sample only had myxml, level<n>, name, and description
elements which all got processed.
If those level<n> elements have other child elements you do not want to
process then change the
<xsl:apply-templates select="*[not(self::name) and
not(self::description)]" />
to
<xsl:apply-templates select="*[starts-with(local-name(), 'level')]"/>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
