Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 4th, 2007, 05:09 AM
Registered User
 
Join Date: Nov 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with namespace declaration

Hi,

I'm trying to transform some XML that begins with the following:

<?xml version="1.0" encoding="UTF-8"?>
<release xmlns="[url of xsd]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="[url of xsd]">

... this doesn't work. When I try transforming, I am left with an empty XML document, with only an empty root element.

If I change the tag to this:

<?xml version="1.0" encoding="UTF-8"?>
<release xmlns="[url of xsd]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="[url of xsd]">

... then everything works fine.

My XSL looks like this:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.juno.co.uk/digital BulkImportSchema.xsd" xmlns:jd="[my domain]" xmlns:sc="[url of their XSD]">
  <xsl:output method="xml" indent="yes"/>
  <xsl:template match="/">
    <xsl:element name="transformedRelease">
      <xsl:apply-templates select="release"></xsl:apply-templates>
    </xsl:element>
  </xsl:template>
  <xsl:template match="release">

     ..... etc ....


My question is, is the XML I've been given possible to transform, and if it is, how do I do it? Or do I need to request a different format?

cheers,
Alex


 
Old April 4th, 2007, 05:14 AM
Registered User
 
Join Date: Nov 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry I messed up the second bit, it should be :
If I change the tag to this:

<?xml version="1.0" encoding="UTF-8"?>
<release xmlns:xsd="[url of xsd]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="[url of xsd]">

 
Old April 4th, 2007, 06:55 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Please follow the link labelled "default namespace" in the sticky post at the start of this forum. When you refer to an element in a namespace from an XPath expression, the name must be prefixed, even if in the source document it is your default namespace.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Namespace problem Harshal123 BOOK: Beginning XML, 4th Ed ISBN: 978-0-470-11487-2 1 October 21st, 2008 06:35 AM
namespace problem gantait XSLT 5 February 19th, 2007 12:51 AM
How to handle default namespace declaration? moltenlava XSLT 1 January 4th, 2006 06:49 PM
namespace problem muki XSLT 1 November 13th, 2005 12:25 PM
Namespace Problem JRMotz BOOK: ASP.NET Website Programming Problem-Design-Solution 1 November 12th, 2005 03:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.