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 10th, 2009, 06:25 PM
Authorized User
 
Join Date: Jan 2009
Posts: 17
Thanks: 2
Thanked 0 Times in 0 Posts
Default XSLT and element name with a : in them

Hi All,

I'm trying to write a xls to transform one XML document to another. I have it working except for one case: when my input.xml has elements with a name with a colon in them.

For example:

<A>
<B:C xlmns ="">
5
</B:C>
</A>

My script tries to do something like this:

<xsl:template match="A">
<xsl:element name="Item">
<xsl:attribute name="test"><xsl:value-of select="B:C"/></xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>

The error I keep getting is "reference to undeclared namespace prefix: 'B'". This is because its thinking that B:C is a prefix when in fact the whole name is B:C. Is there a way to escape this special character so that it parses the whole element name with a colon in it?

Thanks!

jiggs
 
Old June 10th, 2009, 06:43 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

XSLT will only work on XML input that is namespace-well-formed, which means that a name containing a colon is always treated according to the rules in the namespaces specification, whether it appears in the source document or in a stylesheet (including within an XPath expression).
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT - fetching element value without getting the samridhis XSLT 4 August 11th, 2008 03:30 AM
Urgent:XSLT element value selection and condition amhicraig XSLT 1 December 4th, 2007 07:57 PM
Element value type in XSLT 1.0 NEO1976 XSLT 9 February 13th, 2007 11:11 AM
Copy element into complexType in XSLT 2BOrNot2B XSLT 3 December 20th, 2006 09:09 AM
Write XML element into textbox with XSLT tcstom XSLT 4 July 5th, 2006 04:08 AM





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