XML namespace handling in xslt -


i need convert 1 xml format xml using xslt.initially tried without namespace , got it. when tried name space xmlns="http://ws.wso2.org/dataservice" not working without prefixes xmlns:d="http://ws.wso2.org/dataservice" in given xml file

<test xmlns="http://ws.wso2.org/dataservice">  <datarows>   <name>name</name>  </datarows>  <datarows>   <name>karthik</name>  </datarows>  </testcsv> 

i need xml file after xsl transformation

<head> <names>name</names> <names>karthik</names> </head> 

help me xslt

i tried xslt

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0"     xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:d="http://ws.wso2.org/dataservice" exclude-result-prefixes="d" >     <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>      <namespace-alias stylesheet-prefix="xsl" result-prefix="#default"/>       <xsl:template match="/">     <head>         <xsl:for-each select="testcsv/datarows">             <names>                 <xsl:value-of select="name" />             </names>         </xsl:for-each>         </head>     </xsl:template> </xsl:stylesheet> 

as understand (or could) not change xmlns declaration in xml (perhaps because generated somewhere else). have use xml node prefix in xlst.

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0"     xmlns:xsl="http://www.w3.org/1999/xsl/transform"     xmlns:d="http://ws.wso2.org/dataservice"     exclude-result-prefixes="d"     >     <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>     <xsl:template match="/">         <head>             <xsl:for-each select="d:testcsv/d:datarows" >                 <names>                     <xsl:value-of select="d:name" />                 </names>             </xsl:for-each>         </head>     </xsl:template> </xsl:stylesheet> 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -