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 June 27th, 2005, 04:45 PM
Registered User
 
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default xsl namespace

I am quite new to xsl . I hav problem with namespaces.
the xml file is

<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:dc="http://purl.org/dc/elements/1.1/" >
  <dc:format>text</dc:format>
  <dc:title>ab</dc:title>
  <Type>general</Type>

  ...........


 the xsl file is

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes"/>
   <xsl:template match="/">
<xsl:text>
</xsl:text>

<xsl:call-template name="copyNode">
    <xsl:with-param name="Name" select="//dc:title"/>
</xsl:call-template>
<xsl:call-template name="copyNode">
        <xsl:with-param name="Name" select="//dc:format"/>
</xsl:call-template>
<xsl:call-template name="copyNode">
   <xsl:with-param name="Name" select="//Type"/>
</xsl:call-template>
</xsl:template>

<xsl:template name="copyNode">
    <xsl:param name="Name"/>
    <xsl:if test="$Name">
        <xsl:copy-of select="$Name"/>

        <xsl:text>
        </xsl:text>
    /xsl:if>
</xsl:template>


the problem is , I am able to extract the title and format values which has a dc prefix in the namespace, but I am not able to get the
values for Type which has no dc prefix in the xml. It would be grt if someone can help me out with this

 
Old June 27th, 2005, 05:29 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Are you sure that your source XML document doesn't contain a default namespace declaration

xmlns="something"

which would move <Type> into a different namespace?

(people often snip the very thing that's causing the trouble, because they didn't realise it was important...)



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 27th, 2005, 05:43 PM
Registered User
 
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the quick reply. The source xml document had a default namespace declaration

 xmlns="http://purl.oclc.org/NET/EMSL/BSE" where in it is redirected to a different url.

 It doesn't seem to work with the xmlns namespace included too.



 
Old June 29th, 2005, 10:09 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

See http://www.dpawson.co.uk/xsl/sect2/N5536.html especially number 23.

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl:param and xsl:apply-templates' "select" newbieboobers XSLT 1 March 25th, 2008 07:23 PM
Pass link values as xsl:parameter to php5 then xsl pauljr8 XSLT 1 July 2nd, 2007 10:32 PM
Namespace in XML preventing XSL for-each geordaa XSLT 1 February 5th, 2007 06:14 AM
XSL namespace-alias problem cheez XSLT 4 August 22nd, 2006 03:20 AM
XSL Transform with xsl string NOT xsl file skin XSLT 0 June 16th, 2003 07:30 AM





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