views:

70

answers:

1

I'm trying to match certain elements using XSLT. My input document is very large and the source XML fails to load after processing the following code (consider especially the first line).

    <xsl:template match="XMI/XMI.content/Model_Management.Model/Foundation.Core.Namespace.ownedElement/Model_Management.Package/Foundation.Core.Namespace.ownedElement">
    <rdf:RDF>
        <rdf:Description rdf:about="">

            <xsl:for-each select="Foundation.Core.Class">       
                <xsl:for-each select="Foundation.Core.ModelElement.name">
                    <owl:Class rdf:ID="@Foundation.Core.ModelElement.name" />
                </xsl:for-each>
            </xsl:for-each>     

        </rdf:Description>
    </rdf:RDF>
</xsl:template>

Apparently the XSLT fails to load after "Model_Management.Model". The PHP code is as follows:

    if ($xml->loadXML($source_xml) == false) {
    die('Failed to load source XML: ' . $http_file);
}

It then fails to perform loadXML and immediately dies. I think there are two options now.

1) I should set a maximum executing time. Frankly, I don't know how that I do this for the built-in PHP 5 XSLT processor. 2) Think about another way to match.

What would be the best way to deal with this?

The input document can be found at http://krisvandenbergh.be/uml_pricing.xml

Any help would be appreciated! Thanks.

A: 

If you can get a match on XMI.content, then it is not the "." in Model_Management.Model that is throwing you off.

I seems to me that since you are looking for elements that are 6 layers down, there may be an easier solution. Have you tried this:

<xsl:template match="Foundation.Core.Namespace.ownedElement">
    <!-- other code -->
</xsl:template>

The match in the template tag does not have to be that specific usually. The select in your <xsl:apply-templates> where you call the template should be as specific as possible.

Seattle Leonard
Ok, now it does work somehow. However, the xsl returns a lot of strings from other elements I didn't ask for. Should I match all of these elements and output nothing? As in:<xsl:template match="XMI.header"><!-- no code here --></xsl:template><xsl:template match="Model_Management.Subsystem"><!-- no code here --></xsl:template>and so on ..
Kris Van den Bergh