I'm doing a project for my class and one of the goals is to transform one XML to other using XSLT.
I kinda managed to obtain the info within the original XML file but I don't know why I can't "print" the tag's.

XML file (original):

<?xml version="1.0" encoding="ISO-8859-1"?>

<?xml-stylesheet type="text/xsl" href = "fotografiasXSLT1.xsl"?>
<Albuns xmlns="http://www.dei.isep.ipp.pt/lprog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dei.isep.ipp.pt/lprog fotografiasXSD.xsd">
    <Album ID="3">
        <Dono dono="Daniel Bastos" />
        <NomeAlbum nomeAlbum="Artbook" />
        <DataCriacao>2013-06-10</DataCriacao><!-->formato das datas: YYYY-MM-DD<-->
        <DataModificacao>2013-08-16</DataModificacao>
        <Descricao descricao="PhotoShop Covers" />
        <Fotografias>
            <Fotografia FotografiaID="9">
                <NomeFotografia nomeFotografia="Cover Psicose 2.0 (com frase).png" />
                <link>http://goo.gl/XQ1GJv</link>
                <DataCriacao>2012-09-06</DataCriacao>
                <HorasCriacao>17:39:59</HorasCriacao>
                <Tipo ficheiro="png" />
                <Autor autor="Daniel Bastos" />
                <Localizacao>
                    <Cidade>Maia</Cidade>
                    <Pais>Portugal</Pais>
                </Localizacao>
                <Dimensoes>
                    <Largura>1050</Largura>
                    <Altura>1680</Altura>
                </Dimensoes>
                <TamanhoFotografia>1.34</TamanhoFotografia>
            </Fotografia>            
        </Fotografias>
    </Album>
</Albuns>

XSLT:

<?xml version="1.0" encoding="ISO-8859-1"?><!-- DWXMLSource="fotografiasXML.xml" -->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:output method="xml" indent="yes" encoding="ISO-8859-1"/>

    <xsl:template match="/Fotografias">
        <xsl:copy>
            <Fotografias>
                <xsl:apply-templates select="Fotografia/*"/>
            </Fotografias>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Fotografia/*">
        <xsl:copy>
            <Fotografia>
                <xsl:value-of select="."/>
            </Fotografia>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Fotografia/nomeFotografia">
        <xsl:copy>
            <xsl:value-of select="translate(., 'abcdefghijklmnopqrstuvwxyz', '')"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Fotografia/link">
        <xsl:copy>
            <xsl:value-of select="translate(., 'abcdefghijklmnopqrstuvwxyz', '')"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Fotografia/dataCriacao">
        <xsl:copy>
            <xsl:value-of select="translate(., 'abcdefghijklmnopqrstuvwxyz', '')"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Fotografia/horaCriacao">
        <xsl:copy>
            <xsl:value-of select="translate(., 'abcdefghijklmnopqrstuvwxyz', '')"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Fotografia/tipo">
        <xsl:copy>
            <xsl:value-of select="translate(., 'abcdefghijklmnopqrstuvwxyz', '')"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Fotografia/autor">
        <xsl:copy>
            <xsl:value-of select="translate(., 'abcdefghijklmnopqrstuvwxyz', '')"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Fotografia/localizacao">
        <xsl:copy>
                <xsl:apply-templates select="localizacao/*"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Fotografia/localizacao/*">
        <xsl:copy>
                <xsl:value-of select="."/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Fotografia/localizacao/cidade">
        <xsl:copy>
            <xsl:value-of select="translate(., 'abcdefghijklmnopqrstuvwxyz', '')"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Fotografia/localizacao/pais">
        <xsl:copy>
            <xsl:value-of select="translate(., 'abcdefghijklmnopqrstuvwxyz', '')"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Fotografia/dimensoes">
        <xsl:copy>
                <xsl:apply-templates select="dimensoes/*"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Fotografia/dimensoes/*">
        <xsl:copy>
                <xsl:value-of select="."/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Fotografia/dimensoes/largura">
        <xsl:copy>
            <xsl:value-of select="translate(., 'abcdefghijklmnopqrstuvwxyz', '')"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Fotografia/dimensoes/altura">
        <xsl:copy>
            <xsl:value-of select="translate(., 'abcdefghijklmnopqrstuvwxyz', '')"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="Fotografia/tamanhoFotografia">
        <xsl:copy>
            <xsl:value-of select="translate(., 'abcdefghijklmnopqrstuvwxyz', '')"/>
        </xsl:copy>
    </xsl:template>

</xsl:stylesheet>

XML (output):

<?xml version="1.0" encoding="ISO-8859-1"?>



        2013-06-10
        2013-08-16




                http://goo.gl/XQ1GJv
                2012-09-06
                17:39:59



                    Maia
                    Portugal


                    1050
                    1680

                1.34

Can anyone show me what I'm doing wrong or sugest something?
Thanks in advance (ps.: I'm portuguese so don't find odd if the tag names are in portuguese :b and sorry for the long post :c)

Edited 2 Years Ago by Big-D2xL

a result which I mean to output xml

I gave you an example generated
think of namespace

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- DWXMLSource="fotografiasXML.xml" -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:a="http://www.dei.isep.ipp.pt/lprog">
    <xsl:output method="xml" indent="yes" encoding="ISO-8859-1"/>
    <xsl:template match="a:Albuns">
        <xsl:apply-templates select="a:Album"/>
    </xsl:template>
    <xsl:template match="a:Album">
        <xsl:apply-templates select="a:Fotografias"/>
    </xsl:template>
    <xsl:template match="a:Fotografias">
        <xsl:copy-of select="a:Fotografia"/>
    </xsl:template>
</xsl:stylesheet>

Hi!
I had been following an example I found online and it didn't used any namespaces... I thought and tried to used it but the way I had the xslt made, it would be showing the tags like this: <Fotografria xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:a="http://www.dei.isep.ipp.pt/lprog"> and I didn't want that. With what you showed me here, it works like a charm!

Thanks a lot! ;)

This question has already been answered. Start a new discussion instead.