• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Namespace problem in xslt

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have some xml that I need to transform to an xml output. However, when the xslt does a xpath lookup on the xml, it cannot find the xml element. This is because it cannot find the namespace.

How do I get this to work if I cannot change the xml, but I can modify the xslt?


<getClientRequest xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://resources.vero.co.nz/schemas/ClientEnabler">
<versionId>2.0</versionId>
<client>
<clientId>
<value>7246272</value>
</clientId>
</client>
</getClientRequest>





<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:solvit="http://resources.vero.co.nz/schemas/ClientEnabler"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2004/10/xpath-functions"
xmlns:xdt="http://www.w3.org/2004/10/xpath-datatypes"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
exclude-result-prefixes="xsl xsi xdt fn xs #default">

<xsl:template match="*"/>
<xsl:template match="solvit:getClientRequest">
<xsl:element name="SOLVIT">
<xsl:element name="XMLHead">
<xsl:element name="Service">ENQUIRECLIENT</xsl:element>
</xsl:element>
<xsl:element name="XMLData">
<xsl:element name="Client">
<xsl:element name="CLTKY"><xsl:value-of select="client/clientId/value"/></xsl:element>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:template>

</xsl:stylesheet>
[ March 05, 2006: Message edited by: Blikkies Marais ]
 
Blikkies Marais
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know that the xslt does not have a default namespace, but a namespace of xmlns:solvit="http://resources.vero.co.nz/schemas/ClientEnabler". But when I make this the default namespace (to match the xml) it gets no output. Is one not allowed to define default namespaces in xlt's?
[ March 05, 2006: Message edited by: Blikkies Marais ]
 
Blikkies Marais
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found the solution

http://www.topxml.com/people/bosley/defaultns.asp
 
Note to self: don't get into a fist fight with a cactus. Command this tiny ad to do it:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic