0

I have this xml

<?xml-stylesheet type="text/xsl" href="almacen1.xsl"?>
<almacen>
    <iva>1.21</iva>
    <producto id="p0001">
        <nombre>SET DE LLAVES HEXÁGONAS</nombre>
        <marca pagina="www.suconel.com">>SUCONEL</marca>
    </producto>
    <producto id="p0002">
        <nombre>Llave para tubo de 8"</nombre>
        <marca pagina="www.accesa.com.uy">ACCESA</marca>
    </producto>
</almacen>

And they ask me to put functional links using the links in the xml, but when I click on the link, it shows this: Error loading style sheet: XPath analysis failed: ':' was not expected

My xslt code is this:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
        <html>
            <body>
                <section>
                    <xsl:for-each select="//producto">
                        <a target="_blank">
                            <xsl:attribute name="href">
                                <xsl:value-of select="http://{marca/@pagina}"/>
                            </xsl:attribute>
                            <xsl:value-of select="marca/@pagina"/>
                        </a>
                    </xsl:for-each>
                </section>
            </body> 
        </html>
    </xsl:template>
</xsl:stylesheet>

Anyone knows how?

2

I fixed it. I put: <xsl:attribute name="href">http://<xsl:value-of select="marca/@pagina"/><xsl:attribute> and it worked.

  • Don't forget to accept your own answer so future users can find the question as answered. – willman Jan 26 at 20:34
0

You have to escape/encode those values to to make it XSL-safe. If you are using XSL 2.0, you can use encode-for-uri.

Not the answer you're looking for? Browse other questions tagged or ask your own question.