You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Sascha Punzmann <SP...@web.de> on 2005/04/09 12:49:17 UTC

difference function in XALAN C 1.9.0

Hi, im using the above verison of xalan. Now I want to use the 
difference function! It looks like this:

------------------------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:set="http://exslt.org/set"
                xmlns:common="http://exslt.org/common"
                xmlns:xalan="http://xml.apache.org/xalan">

  <xsl:output method="xml" indent="yes" encoding="iso-8859-1"/>
  <xsl:strip-space elements="*"/>

  <xsl:variable name="xbo_db" select="document('c:\temp_step1.xml')"/>
  <xsl:variable name="xbo" select="/"/>  
  <xsl:variable name="differenceA" select="xalan:difference($xbo, 
$xbo_db)" />

  <xsl:template match="/">
    <output>
      <xsl:for-each select="$differenceA" >
        <xsl:element name="test" >
          <xsl:attribute name="size"><xsl:value-of 
select="count($differenceA)" /></xsl:attribute>
          <xsl:attribute name="abc"><xsl:value-of select="@name" 
/></xsl:attribute>
          <xsl:attribute name="efg"><xsl:value-of select="@TS-Key" 
/></xsl:attribute>        
        </xsl:element>
      </xsl:for-each>
    </output>
  </xsl:template>
</xsl:stylesheet>
------------------------------------------------------------------------------------------------------------------------------------------------

XALAN doesen't throw any error or something! I simply get no output from 
$differenceA! Maybe I use it in the wrong way! Any suggestions?

Greetz

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


Re: difference function in XALAN C 1.9.0

Posted by da...@us.ibm.com.
> XALAN doesen't throw any error or something! I simply get no output from 

> $differenceA! Maybe I use it in the wrong way! Any suggestions?

Can you be more specific about what you mean by "I simply get no output 
from $differenceA?"  What output did you get and what output do you 
expect?  It's difficult for anyone to diagnose the problem if you don't 
provide enough information.

I createed two trivial source documents that contain just an empty root 
element and ran your stylesheet, which produced the following result:

<?xml version="1.0" encoding="iso-8859-1"?>
<output xmlns:fo="http://www.w3.org/1999/XSL/Format" 
xmlns:set="http://exslt.org/set" xmlns:common="http://exslt.org/common" 
xmlns:xalan="http://xml.apache.org/xalan">
<test size="1" abc="" efg=""/>
</output>

Are you expecting the new attributes "abc" and "efg" to have a non-empty 
value?  If so, the problem is problem is here in your stylesheet:

<xsl:variable name="xbo_db" select="document('c:\temp_step1.xml')"/>
<xsl:variable name="xbo" select="/"/> 
<xsl:variable name="differenceA" select="xalan:difference($xbo, $xbo_db)" 
/>

The variable "xbo_db" contains a single root node (if the call to the 
document function succeeds), and the variable "xbo" contains a second root 
node, which is the root node of the primary source tree.  You then create 
a third variable "differenceA", which contains the difference between 
"xbo" and "xbo_db", which, since there are only two nodes, will also 
contain the root node of the primary source tree.  Since root nodes do not 
have attributes, the select expressions on the xsl:attribute elements will 
result in empty node-sets.

Finally, since the difference function operates on node identity, it's not 
clear what you are trying to accomplish by using it with two node-sets 
that come from different source trees.

The Mulberry Technologies XSL list is the best place to post questions 
like this:

http://www.mulberrytech.com/xsl/xsl-list/index.html

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org