View Single Post
  #1 (permalink)  
Old March 12th, 2007, 05:49 AM
Tomi Tomi is offline
Authorized User
 
Join Date: Jul 2006
Location: Valencia, Valencia, Spain.
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default template match doesnt match the required node

Hello all,

I'm having problems when matching the nodes of an xml file.I think there is a problem with namespaces but I cant figure out which one.Ive already read the link http://www.dpawson.co.uk/xsl/sect2/N...tml#d7563e1012 but it didnt help me in my specific problem.

XSL version 2.0

Processor:Saxon 8

XML input:

<?xml version="1.0" encoding="UTF-8"?>
<d2LogicalModel xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://datex2.eu/schema/1_0/1_0" modelBaseVersion="1.0" xsi:schemaLocation="http://datex2.eu/schema/1_0/1_0 C:\DOCUME~1\totres\Escritorio\d1d2transf\DATEXI~1\ DATEXIISchema_1_0_1_0\DATEXIISchema_1_0_1_0.xsd">
    <exchange>
        <supplierIdentification>
            <country>es</country>
            <nationalIdentifier>es001</nationalIdentifier>
        </supplierIdentification>
    </exchange>
    <payloadPublication xsi:type="SituationPublication" lang="es">
        <publicationTime>2007-02-21T09:32:00+01:00</publicationTime>
        <publicationCreator>
            <country>es</country>
            <nationalIdentifier>es001</nationalIdentifier>
        </publicationCreator>
        <situation id="GUID254746">
            <headerInformation>
                <confidentiality>noRestriction</confidentiality>
                <informationStatus>real</informationStatus>
            </headerInformation>
            <situationRecord xsi:type="Activities" id="GUID254746_3O">
                <situationRecordCreationTime>2006-04-04T12:16:00+01:00</situationRecordCreationTime>
                <situationRecordVersion>4</situationRecordVersion>
                <situationRecordVersionTime>2006-04-04T12:16:00+01:00</situationRecordVersionTime>
                <situationRecordFirstSupplierVersionTime>2006-04-04T12:16:00+01:00</situationRecordFirstSupplierVersionTime>
                <probabilityOfOccurrence>certain</probabilityOfOccurrence>
                <validity>
                    <validityStatus>active</validityStatus>
                    <validityTimeSpecification>
                        <overallStartTime>2006-10-17T14:00:00+02:00</overallStartTime>
                        <overallEndTime>2006-10-17T16:00:00+02:00</overallEndTime>
                    </validityTimeSpecification>
                </validity>
                <groupOfLocations>
                    <locationContainedInGroup xsi:type="Linear">
                        <alertCLinear xsi:type="AlertCMethod4Linear">
                            <alertCLocationCountryCode>E</alertCLocationCountryCode>
                            <alertCLocationTableNumber>17</alertCLocationTableNumber>
                            <alertCLocationTableVersion>2.0</alertCLocationTableVersion>
                            <alertCDirection>
                                <alertCDirectionCoded>both</alertCDirectionCoded>
                            </alertCDirection>
                            <alertCMethod4PrimaryPointLocation>
                                <alertCLocation>
                                    <specificLocation>61602</specificLocation>
                                </alertCLocation>
                                <offsetDistance>
                                    <offsetDistance>2099</offsetDistance>
                                </offsetDistance>
                            </alertCMethod4PrimaryPointLocation>
                            <alertCMethod4SecondaryPointLocation>
                                <alertCLocation>
                                    <specificLocation>61608</specificLocation>
                                </alertCLocation>
                                <offsetDistance>
                                    <offsetDistance>2099</offsetDistance>
                                </offsetDistance>
                            </alertCMethod4SecondaryPointLocation>
                        </alertCLinear>
                    </locationContainedInGroup>
                </groupOfLocations>
                <authorityOperationType>policeCheckPoint</authorityOperationType>
            </situationRecord>
        </situation>
    </payloadPublication>
</d2LogicalModel>


XSL:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" >
    <xsl:param name="filtro"/>
    <!--
    Template Principal
    -->
    <xsl:template match="/">
        <xsl:apply-templates select="d2LogicalModel"/>

    </xsl:template>
    <!--
    Template
    -->
    <xsl:template match="d2LogicalModel">

        <xsl:copy>
            <xsl:copy-of select="@*"/>

            <xsl:apply-templates select="exchange"/>
            <xsl:apply-templates select="payloadPublication"/>
        </xsl:copy>
    </xsl:template>
    <!--
    Template
    -->
    <xsl:template match="exchange">
        <xsl:copy>

            <xsl:copy-of select="*"/>
        </xsl:copy>
    </xsl:template>
    <!--
    Template
    -->
    <xsl:template match="payloadPublication">
        <xsl:copy>
            <xsl:copy-of select="child::publicationTime"/>
            <xsl:copy-of select="child::publicationCreator"/>
            <xsl:apply-templates select="situation"/>
        </xsl:copy>
    </xsl:template>
    <!--
    Template
    -->
    <xsl:template match="situation">
        <xsl:copy>
            <xsl:copy-of select="@*"/>
            <xsl:copy-of select="child::headerInformation"/>
            <xsl:if test="count(child::situationRecord[@xsi:type = $filtro]) != 0 ">
                <xsl:apply-templates select="situationRecord"/>
            </xsl:if>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="situationRecord">
        <xsl:if test=" @xsi:type = $filtro ">
            <xsl:copy>
                <xsl:copy-of select="@*"/>
                <xsl:copy-of select="*"/>
            </xsl:copy>
        </xsl:if>
    </xsl:template>
</xsl:stylesheet>


Ive been debugging it with xml spy and I found that only the first template is executed, none of the nodes of the xml are matched except the root node('/').

Any ideas?

I will appreciate the help.

Thanks.

Tomi.



Reply With Quote