dneranjan
dneranjan

Reputation: 136

XML to XML trasformation using Xslt

I'm newly for the xslt and Xpath.i need to transform xml to another xml file using xslt. so i need to get Name element.i'm using xpath.but getting below error when i run my xslt. anything i missing or went wrong ?

Error: net.sf.saxon.s9api.SaxonApiException: org.xml.sax.SAXParseException; lineNumber: 22; columnNumber: 22; The prefix "arr" for element "arr:string" is not bound.

Input file.XML

<Accounts>
<Account>
    <Name></Name>
</Account>
<Accounts>

need to get <Name> element

my xpath is (this is not fully xslt file. included only get name element code)

         <arr:string>
            <xsl:value-of select="/Accounts/Account"></xsl:value-of>
         </arr:string>

output is -:

            <qqq:Fields>
               <arr:string>Name</arr:string>
               <arr:string>XXX</arr:string>
               <arr:string>xxxxx</arr:string>
               <arr:string>xxxxx</arr:string>
            </qqq:Fields>

Upvotes: 0

Views: 126

Answers (1)

Honza Hejzl
Honza Hejzl

Reputation: 884

You need some declaration of that namespace.

Like:

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

Or:

<arr:string xmlns:arr="http://myarr.org">
    <xsl:value-of select="/Accounts/Account"/>
</arr:string>

Try to check: http://www.w3schools.com/xml/xml_namespaces.asp

Upvotes: 1

Related Questions