Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Coverting the Elements to Attributes, of the an XML file - giving another XML file

From: Martin Honnen <mahotrash@-----.-->
To: 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/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent