[GeoNetwork-users] XSLT transformation file problem

Hello.
I have a problem with xml file transformation using xslt file.
The problem is that <xsl:apply-templates select="msxsl:node-set($variable)"
/> doesn't work as I thought it should.
Xslt file doesn't treat the variable $variable as an address but as a text
string and displays it on the screen.
If I tried to put correct path (the result of concatenation --> see below in
examples) as a value of $variable it works propertly and the template is
called. I think that making variable $variable seen as an address can be the
key to the solve the problem.

I add all files below.
-----------------------------------------------------------------------------------------------------------------------------------------------
Xml file we want to transform.

<?xml version="1.0" encoding="utf-8"?>
<MD_Metadata xmlns="http://www.isotc211.org/2005/gmd&quot;
uuid="3b791ec3-2e60-46e1-a7c6-f60f8ef89581"
xmlns:gco="http://www.isotc211.org/2005/gco&quot;&gt;
<TimePeriod>
  <relatedTime>
    <TimePeriod>
      <relatedTime>
        <TimePeriod>
        </TimePeriod>
      </relatedTime>
      <beginPosition>2_wartosc</beginPosition>
    </TimePeriod>
  </relatedTime>
  <beginPosition>1_wartosc</beginPosition>
</TimePeriod>
</MD_Metadata>
-----------------------------------------------------------------------------------------------------------------------------------------------
Xml file we expect after transformation.

<?xml version="1.0" encoding="utf-8"?>
<MD_Metadata xmlns="http://www.isotc211.org/2005/gmd&quot;
uuid="3b791ec3-2e60-46e1-a7c6-f60f8ef89581"
xmlns:gco="http://www.isotc211.org/2005/gco&quot;&gt;
<gmd:TimePeriod>
  <gmd:relatedTime>
    <gmd:TimePeriod>
      <gmd:relatedTime>
        <gmd:TimePeriod>
        </gmd:TimePeriod>
      </gmd:relatedTime>
      <gmd:beginPosition>2_wartosc</gmd:beginPosition>
    </gmd:TimePeriod>
  </gmd:relatedTime>
  <gmd:beginPosition>1_wartosc</gmd:beginPosition>
</gmd:TimePeriod>
</MD_Metadata>
-----------------------------------------------------------------------------------------------------------------------------------------------
Xml with result of transformation in our case.

<?xml version="1.0" encoding="utf-8"?>
<MD_Metadata uuid="3b791ec3-2e60-46e1-a7c6-f60f8ef89581"
xmlns="http://www.isotc211.org/2005/gmd&quot;
xmlns:gmd="http://www.isotc211.org/2005/gmd&quot;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
  <gmd:TimePeriod>
    <gmd:relatedTime>
      <gmd:TimePeriod>
        <gmd:relatedTime
/>/gmd:MD_Metadata/gmd:TimePeriod/gmd:relatedTime/gmd:TimePeriod/gmd:beginPosition</gmd:TimePeriod>
   
</gmd:relatedTime>/gmd:MD_Metadata/gmd:TimePeriod/gmd:beginPosition</gmd:TimePeriod>
</MD_Metadata>
-----------------------------------------------------------------------------------------------------------------------------------------------
Xsl transformation file.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.isotc211.org/2005/gmd&quot;
xmlns:gmd="http://www.isotc211.org/2005/gmd&quot;
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;
xmlns:xsl="http://www.w3.org/1999/XSL/Transform&quot;
                xmlns:msxsl="urn:schemas-microsoft-com:xslt">

<xsl:output method="xml" encoding="UTF-8" indent="yes" />

<xsl:template match="/">
  <xsl:apply-templates />
</xsl:template>

<xsl:template match="gmd:MD_Metadata">
  <MD_Metadata uuid="{@uuid}">
    <xsl:apply-templates select="gmd:TimePeriod"/>
  </MD_Metadata>
</xsl:template>
                  
<xsl:template name="for.loop" match="gmd:MD_Metadata/gmd:TimePeriod">
  <xsl:param name="i" select="1"/>
  <!-- this is the main part of address that always occurs -->
  <xsl:param name="wspolne"
select="concat('/gmd:MD_Metadata','/gmd:TimePeriod')"/>
  <!-- this is that part of adress which should be add to the main as many
times as the loop continues -->
  <xsl:param name="dodatek"
select="concat('/gmd:relatedTime','/gmd:TimePeriod')"/>
  <xsl:if test="$i &lt; 3">
    <gmd:TimePeriod>
      <gmd:relatedTime>
        <xsl:call-template name="for.loop">
          <xsl:with-param name="i">
            <xsl:value-of select="$i + 1"/>
          </xsl:with-param>
          <xsl:with-param name="wspolne">
            <!-- connecting two parts of address into one piece -->
            <xsl:value-of select="concat($wspolne,$dodatek)" />
          </xsl:with-param>
        </xsl:call-template>
       </gmd:relatedTime>
      <!-- this is the place where template should be called -->
      <xsl:apply-templates
select="msxsl:node-set(concat($wspolne,'/gmd:beginPosition'))" />
    </gmd:TimePeriod>
  </xsl:if>
</xsl:template>
<!-- template we want to call -->
<xsl:template match="gmd:MD_Metadata/gmd:TimePeriod//gmd:beginPosition">
  <xsl:element name="gmd:beginPosition">
    <xsl:value-of select="."/>
  </xsl:element>
</xsl:template>
                      
</xsl:stylesheet>
-----------------------------------------------------------------------------------------------------------------------------------------------
Thanks in advance.

Cheers,
Ɓukasz

--
View this message in context: http://www.nabble.com/XSLT-transformation-file-problem-tf4756772s18419.html#a13602777
Sent from the geonetwork-users mailing list archive at Nabble.com.