From: Lukasz_Sobotowski <l.s...@go...> - 2007-11-06 08:49:39
|
Hello. I have a problem with xml file transformation using xslt file. The problem is that <xsl:apply-templates select=3D"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.=20 If I tried to put correct path (the result of concatenation --> see below i= n 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 th= e key to the solve the problem.=20 I add all files below. ---------------------------------------------------------------------------= -------------------------------------------------------------------- Xml file we want to transform. <?xml version=3D"1.0" encoding=3D"utf-8"?> <MD_Metadata xmlns=3D"http://www.isotc211.org/2005/gmd" uuid=3D"3b791ec3-2e60-46e1-a7c6-f60f8ef89581" xmlns:gco=3D"http://www.isotc211.org/2005/gco"> <TimePeriod> =09<relatedTime> =09=09<TimePeriod> =09=09=09<relatedTime> =09=09=09=09<TimePeriod>=09=09 =09=09=09=09</TimePeriod> =09=09=09</relatedTime> =09=09=09<beginPosition>2_wartosc</beginPosition> =09=09</TimePeriod> =09</relatedTime> =09<beginPosition>1_wartosc</beginPosition> </TimePeriod> </MD_Metadata> ---------------------------------------------------------------------------= -------------------------------------------------------------------- Xml file we expect after transformation. <?xml version=3D"1.0" encoding=3D"utf-8"?> <MD_Metadata xmlns=3D"http://www.isotc211.org/2005/gmd" uuid=3D"3b791ec3-2e60-46e1-a7c6-f60f8ef89581" xmlns:gco=3D"http://www.isotc211.org/2005/gco"> <gmd:TimePeriod> =09<gmd:relatedTime> =09=09<gmd:TimePeriod> =09=09=09<gmd:relatedTime> =09=09=09=09<gmd:TimePeriod>=09=09 =09=09=09=09</gmd:TimePeriod> =09=09=09</gmd:relatedTime> =09=09=09<gmd:beginPosition>2_wartosc</gmd:beginPosition> =09=09</gmd:TimePeriod> =09</gmd:relatedTime> =09<gmd:beginPosition>1_wartosc</gmd:beginPosition> </gmd:TimePeriod> </MD_Metadata> ---------------------------------------------------------------------------= -------------------------------------------------------------------- Xml with result of transformation in our case.=20 <?xml version=3D"1.0" encoding=3D"utf-8"?> <MD_Metadata uuid=3D"3b791ec3-2e60-46e1-a7c6-f60f8ef89581" xmlns=3D"http://www.isotc211.org/2005/gmd" xmlns:gmd=3D"http://www.isotc211.org/2005/gmd" xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" xmlns:msxsl=3D"urn:schemas-microsoft-com:xslt"> <gmd:TimePeriod> <gmd:relatedTime> <gmd:TimePeriod> <gmd:relatedTime />/gmd:MD_Metadata/gmd:TimePeriod/gmd:relatedTime/gmd:TimePeriod/gmd:beginP= osition</gmd:TimePeriod> =20 </gmd:relatedTime>/gmd:MD_Metadata/gmd:TimePeriod/gmd:beginPosition</gmd:Ti= mePeriod> </MD_Metadata> ---------------------------------------------------------------------------= -------------------------------------------------------------------- Xsl transformation file. <?xml version=3D"1.0" encoding=3D"UTF-8"?> <xsl:stylesheet version=3D"1.0" =09xmlns=3D"http://www.isotc211.org/2005/gm= d" =09 xmlns:gmd=3D"http://www.isotc211.org/2005/gmd"=09 =09=09=09=09=09=09=09=09xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-insta= nce"=20 xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform" =09=09=09=09=09=09=09=09xmlns:msxsl=3D"urn:schemas-microsoft-com:xslt"> <xsl:output method=3D"xml" encoding=3D"UTF-8" indent=3D"yes" /> <xsl:template match=3D"/"> =09<xsl:apply-templates /> </xsl:template> <xsl:template match=3D"gmd:MD_Metadata"> =09<MD_Metadata uuid=3D"{@uuid}"> =09=09<xsl:apply-templates select=3D"gmd:TimePeriod"/> =09</MD_Metadata> </xsl:template> =09=09=09=09=09=09=09=09=09 <xsl:template name=3D"for.loop" match=3D"gmd:MD_Metadata/gmd:TimePeriod"> =09<xsl:param name=3D"i" select=3D"1"/> =09<!-- this is the main part of address that always occurs --> =09<xsl:param name=3D"wspolne" select=3D"concat('/gmd:MD_Metadata','/gmd:TimePeriod')"/> =09<!-- this is that part of adress which should be add to the main as many times as the loop continues --> =09<xsl:param name=3D"dodatek" select=3D"concat('/gmd:relatedTime','/gmd:TimePeriod')"/>=09=09=09=09=09=09= =09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09=09 =09<xsl:if test=3D"$i < 3">=20 =09=09<gmd:TimePeriod> =09=09=09<gmd:relatedTime> =09=09=09=09<xsl:call-template name=3D"for.loop"> =09=09=09=09=09<xsl:with-param name=3D"i"> =09=09=09=09=09=09<xsl:value-of select=3D"$i + 1"/> =09=09=09=09=09</xsl:with-param> =09=09=09=09=09<xsl:with-param name=3D"wspolne"> =09=09=09=09=09=09<!-- connecting two parts of address into one piece --> =09=09=09=09=09=09<xsl:value-of select=3D"concat($wspolne,$dodatek)" /> =09=09=09=09=09</xsl:with-param> =09=09=09=09</xsl:call-template> =09=09=09 </gmd:relatedTime> =09=09=09<!-- this is the place where template should be called --> =09=09=09<xsl:apply-templates select=3D"msxsl:node-set(concat($wspolne,'/gmd:beginPosition'))" /> =09=09</gmd:TimePeriod> =09</xsl:if>=09 </xsl:template> <!-- template we want to call --> <xsl:template match=3D"gmd:MD_Metadata/gmd:TimePeriod//gmd:beginPosition">= =09=09=09=09 =20 =09<xsl:element name=3D"gmd:beginPosition"> =09=09<xsl:value-of select=3D"."/> =09</xsl:element> </xsl:template>=09=09=09 =09=09=09=09=09=09=09=09=09=09=09 </xsl:stylesheet> ---------------------------------------------------------------------------= -------------------------------------------------------------------- Thanks in advance. Cheers, =C5=81ukasz --=20 View this message in context: http://www.nabble.com/XSLT-transformation-fil= e-problem-tf4756772s18419.html#a13602777 Sent from the geonetwork-users mailing list archive at Nabble.com. |