954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

urgent

Please, somebody help. I need to transform xml into xml with xsl.
it´s urgent.
the attach files are the input in XML and output is what the prof. want.

Help-me please

Corin

thanks

Attachments EscolaNatacao_Input.xml (1.52KB) EscolaNatacao_Transformado.xml (1.76KB)
corinport
Newbie Poster
1 post since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

Have fun cheating!

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

	<xsl:template match="/">
		<xsl:apply-templates select="EscolaNatacao"/>
	</xsl:template>

	<xsl:template match="EscolaNatacao">
		<xsl:copy>
			<xsl:apply-templates select="Turma"/>
		</xsl:copy>
	</xsl:template>

	<xsl:template match="Turma">
		<Classe>
			<xsl:apply-templates select="@numero"/>
			<xsl:apply-templates select="FaixaEtaria/@nivel"/>
			<xsl:apply-templates select="FaixaEtaria"/>
			<xsl:apply-templates select="Dias/Dia" />
		</Classe>
	</xsl:template>

	<xsl:template match="@numero">
		<xsl:copy/>
	</xsl:template>

	<xsl:template match="@nivel">
		<xsl:copy/>
	</xsl:template>

	<xsl:template match="FaixaEtaria">
		<Idades>
			<xsl:apply-templates select="@idadeMinima"/>
			<xsl:apply-templates select="@idadeMaxima"/>
		</Idades>
	</xsl:template>

	<xsl:template match="@idadeMinima">
		<Minima>
			<xsl:value-of select="." />
		</Minima>
	</xsl:template>

	<xsl:template match="@idadeMaxima">
		<Maxima>
			<xsl:value-of select="." />
		</Maxima>
	</xsl:template>

	<xsl:template match="Dia" >
		<Data>
			<xsl:attribute name="dia">
				<xsl:value-of select="." />
			</xsl:attribute>
			<xsl:apply-templates select="@hora" />
		</Data>
	</xsl:template>

	<xsl:template match="@hora" >
		<xsl:variable name="hora" select="substring(.,1,2)" />
		<xsl:variable name="minuto" select="substring(.,4,2)"/>		
		<xsl:choose>
			<xsl:when test="$minuto != '00'" >
				<xsl:value-of select="concat($hora, ' horas e ', $minuto, ' minutos')" />
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="concat($hora, ' horas')" />
			</xsl:otherwise>
			</xsl:choose>	
	</xsl:template>	
</xsl:stylesheet>
iceandrews
Junior Poster
185 posts since May 2010
Reputation Points: 10
Solved Threads: 30
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You