Dear all,

Another beginner seeks assistance with XSLT and XPATH ;-)

This is my XML source:

<?xml version="1.0" encoding="UTF-8" ?>
<report xsi:schemaLocation="http://www.callassoftware.com/namespace/pi4 pi4_results_schema.xsd" xmlns="http://www.callassoftware.com/namespace/pi4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <profile_info >
    </profile_info>
    <results>
        <hits rule_id="RUL1" severity="Error">
            <hit type="Image" page="PAG1">
            </hit>
            <hit type="Image" page="PAG2">
                <imagestate image_id="IMG30" v_ppi="127.0" h_ppi="127.0"></imagestate>
            </hit>           
        </hits>
    </results>
</report>

I would like to iterate over all the "hits" and print their page attribut. So far this has not been a succes.
Here is my XSLT:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:pi4="http://www.callassoftware.com/namespace/pi4">
    <xsl:output method="html"/>
    <xsl:template match="/">
        <xsl:for-each select="pi4:hits">
            <xsl:value-of select="//@id"/>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

Can you help?

Thanks,

Rasmus

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:pi4="http://www.callassoftware.com/namespace/pi4">
    <xsl:output method="html"/>
    <xsl:template match="results/hits">
        <xsl:for-each select="hit">
            <xsl:value-of select="@page"/>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>

Hi,

By experimentation I've found that you'll have to indicate/refer to the namespace:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:pi4="http://www.callassoftware.com/namespace/pi4">
	<xsl:output method="html"/>
	<xsl:template match="//pi4:hits">
		<xsl:for-each select="pi4:hit">
			<xsl:value-of select="@page"/>
		</xsl:for-each>
	</xsl:template>
</xsl:stylesheet>

But thank you for your help :cool:

Rasmus

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.