Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


attribute manipulation in XSLT transformation

From: "hq4000@-------.---" <------@-------.--->
To: NULL
Date: 2/3/2006 5:08:00 AM
Given  school #1: contains attributes of name and district
<?xml version="1.0" encoding="utf-8"?>
<School name="Joy" district="Albany">
<Class>A</Class>
<Teacher>Dave</Teacher>
</School>


school #2: missing district attribute; but has additional attribute of
principle
<?xml version="1.0" encoding="utf-8"?>
<School name="Happy" principle="Joe">
<Class>B</Class>
<Teacher>Mary</Teacher>
</School>


I want to have an identity copy without "Class" element.  I think
following would work:


<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


     <!-- Identity transformation -->
     <xsl:template match="@*|node()">
         <xsl:copy>
             <xsl:apply-templates select="@*|node()"/>
         </xsl:copy>
     </xsl:template>


   <!-- Omit Class -->
     <xsl:template match="Class"/>
</xsl:stylesheet>


Also, I want to ensure every school must have name and district
attribute; a school can have additional attribute as original as well.
And the district attribute is forced to have same value of "NY".


That is, running the school #1, I would expect following:
<?xml version="1.0" encoding="utf-8"?>
<School name="Joy" district="NY">
<Teacher>Dave</Teacher>
</School>


And running the school #2, I would expect following:
<?xml version="1.0" encoding="utf-8"?>
<School name="Happy" district="NY" principle="Joe">
<Teacher>Mary</Teacher>
</School>


Now, the question is how can I enhance the stylesheet above to do the
attribute manipulation task?



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