xsl:strip-space will not work for what you want, since "space" means text
nodes, and you want to strip element nodes.

A template rule that matches empty elements is what you want:

   <xsl:template match="*[not(node())]">
   </xsl:template>

or even:

   <xsl:template match="*[length(.) = 0]">
   </xsl:template>

You'll also need the cannonical identity transform template in your
stylesheet:

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

You'll need to put it _before_ the rule that matches empty element nodes.

This is a general XSLT question, not a Xalan-specific one, so I would
suggest you join and post such questions to the Mulberry XSL list:

   http://www.mulberrytech.com/xsl/

Dave



                                                                                
                      
                    Anamitra.Bhattachary                                        
                      
                    [EMAIL PROTECTED]                  To:     [EMAIL 
PROTECTED]                  
                                                cc:     (bcc: David N 
Bertoni/CAM/Lotus)              
                    11/16/2001 04:35 PM         Subject:     stripping xml 
elements without values    
                                                                                
                      
                                                                                
                      



Hi
Is it possibe to write a generic xsl script which will allow me to strip
all elements with null/values like
in xml:
      <PSCAMA class="R">
        <LANGUAGE_CD>ENG</LANGUAGE_CD>
        <AUDIT_ACTN></AUDIT_ACTN>
        <BASE_LANGUAGE_CD>ENG</BASE_LANGUAGE_CD>
        <MSG_SEQ_FLG></MSG_SEQ_FLG>
        <PROCESS_INSTANCE>0</PROCESS_INSTANCE>
        <PUBLISH_RULE_ID></PUBLISH_RULE_ID>
        <MSGNODENAME></MSGNODENAME>
      </PSCAMA>

out xml:
<PSCAMA class="R">
<LANGUAGE_CD>ENG</LANGUAGE_CD>
<BASE_LANGUAGE_CD>ENG</BASE_LANGUAGE_CD>
<PROCESS_INSTANCE>0</PROCESS_INSTANCE>
</PSCAMA>

This is just simple xml file - what I need is a generic way to strip off
all empty tags from any input xml. I was trying to use xsl:strip-space
element - but its giving starnge results. Is there anything currently in
xsl that I can use.??

thanks
Anamitra





Reply via email to