XML XSLT namespaces

gonzalo4b

New Member
I got an xml file with namespace 'tns'. I want to use an xslt without to use 'tns' everywhere, but use a matching template instead with the tns namespace declared once and use that one. I want to match the root tns:cv (xml) to my root cv (xsl) Whats wrong with my xslt, because it displays the xml elements, but not the content in it?\[code\]<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="http://stackoverflow.com/questions/10494966/multiLanguageToSingle.xslt"?><tns:cv xmlns:tns="http://www.i8c.be/CvService/1.0"> <tns:generalLanguage>nl</tns:generalLanguage> <tns:careerPath> <tns:current> <tns:company language="nl"> <tns:companyName></tns:companyName> <tns:description></tns:description> </tns:company> </tns:current> <tns:former> <tns:company language="nl"> <tns:companyName></tns:companyName> <tns:description></tns:description> </tns:company> </tns:former> </tns:careerPath> <tns:companyDetails> <tns:address>\[/code\]I want to use an xsl for the above xml (first few lines):\[code\]<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tns="http://www.i8c.be/CvService/1.0"><xsl:output method="xml" omit-xml-declaration="no" indent="yes" /> <xsl:template match="/"> <xsl:apply-templates select="/tns:cv" /> </xsl:template><xsl:template match="/tns:cv"><cv xsi:schemaLocation="http://www.i8c.be/CvService/1.0 cvDataTemplate.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><xsl:variable name="language" select='"nl"'/> <careerPath> <current> <xsl:for-each select="cv/careerPath/current/company[@language=$language]"> <companyName><xsl:value-of select="companyName"/></companyName> <description><xsl:value-of select="description"/></description> </xsl:for-each> </current> <former> <xsl:for-each select="cv/careerPath/former/company[@language=$language]"> <companyName><xsl:value-of select="companyName"/></companyName> <description><xsl:value-of select="description"/></description> </xsl:for-each> </former> </careerPath>\[/code\]
 
Back
Top