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 October 12th, 2006, 03:45 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default Output Formatting

Hi,

I need to display the following output.

Code:
<InvoiceHeader xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:js-function="//ServerName/DirectoryPath/js-functions">
When I try to code the attribute (xmlns:fo), an error message is displayed due to the appearance of the ':' (I presume). Can anyone help please?

My code is
Code:
<xsl:element name="InvoiceHeader">
  <xsl:attribute name="xmlns:fo">http://www.w3.org/1999/XSL/Format</xsl:attribute>
    <xsl:attribute name="xmlns:js-function">//ServerName/DirectoryPath/js-functions</xsl:attribute>
</xsl:element>
Thanks in advance,


Neal

A Northern Soul
__________________
Neal

A Northern Soul
 
Old October 12th, 2006, 04:06 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

In the XPath data model, attribute nodes and namespace nodes are quite separate animals. They only look the same when the nodes are serialized. You need to create a namespace node, not an attribute node.

For the js-function namespace, you don't just want to create a namespace node, you also want the InvoiceHeader element to be in this namespace. You should create the element as

<xsl:element name="InvoiceHeader" namespace="//ServerName/DirectoryPath/js-functions">

or more simply as

<InvoiceHeader xmlns="//ServerName/DirectoryPath/js-functions">

The namespace node will be created automatically, and you'll therefore get the namespace declaration attribute in the result when it is serialized.

The xmlns:fo namespace is a bit trickier, because you aren't actually using it: creating namespaces that you don't use is a rather unusual requirement. You can do it in 2.0 with

<xsl:namespace name="fo">http://www.w3.org/1999/XSL/Format</xsl:namespace>

In 1.0 the simplest workaround is to create a document dummy.xml:

<dummy xmlns:fo="http://www.w3.org/1999/XSL/Format"/>

and then do

<xsl:copy-of select="document('dummy.xml')/dummy/namespace::fo"/>


Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old October 12th, 2006, 05:12 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default

Thank You

Sorry, I forgot to mention, it is Version 1.0 I'm using.

Neal

A Northern Soul





Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting Time Output braunj ASP.NET 2.0 Basics 0 October 6th, 2008 10:27 PM
Formatting Database Output Gobbles Classic ASP Basics 3 September 25th, 2007 05:08 AM
ASP to Excel - excel output formatting issue mat41 Classic ASP Professional 0 August 13th, 2006 06:41 AM
Formatting Output Colonel Angus SQL Server 2000 3 September 1st, 2004 10:35 AM
Formatting Ben Access 3 February 28th, 2004 05:52 AM





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