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 28th, 2011, 07:15 AM
Authorized User
 
Join Date: Oct 2011
Posts: 30
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Yes.. tyiny to get a static header in my xml

- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope">
- <SOAP-ENV:Header>
<ns:FXTradeVersion xmlns:xs="http://www.w3.org/2001/XMLSchema" ns0:mustUnderstand="1" xsi:type="xs:string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://www.w3.org/2003/05/soap-envelope" xmlns:ns="http://schemas.westpac.com.au/wib/icc/fx/service/tradenotification-1-0">1.0</ns:FXTradeVersion>
</SOAP-ENV:Header>


and then begin the transform.....
 
Old January 31st, 2012, 12:12 PM
Registered User
 
Join Date: Jan 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've been having a very similar problem but I didn't have the luxury of knowing all attributes statically in advance. I solved it in a surprisingly simple way.

The problematic code:
Code:
<xsl:element name="article">
    <xsl:attribute name="xml:id"><xsl:apply-templates select="uut:UUTDescription/@uuid" mode="normalizeUuid"/></xsl:attribute>
    <xsl:attribute name="xsi:schemaLocation">http://docbook.org/ns/docbook docbook.xsd</xsl:attribute>
    <xsl:attribute name="xmlns:xsi">http://www.w3.org/2001/XMLSchema-instance</xsl:attribute>
    <xsl:attribute name="version">5.0</xsl:attribute>
    <xsl:attribute name="xmlns:xlink">http://www.w3.org/1999/xlink</xsl:attribute>
    [...]
</xsl:element>
What I was going for (desired result of transformation):
Code:
<article xml:id="VARIABLE"
xsi:schemaLocation="http://docbook.org/ns/docbook docbook.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="5.0"
xmlns:xlink="http://www.w3.org/1999/xlink">
[...]
</article>
Error I got upon compiling the XSL stylesheet:
Code:
Prefix 'xmlns' is not defined.
What I did:
I shoved the <xsl:apply-templates select="uut:UUTDescription/@uuid" mode="normalizeUuid"/> into a variable such as:
Code:
<xsl:variable name="uuid"><xsl:apply-templates select="tc:TestConfiguration/@uuid" mode="normalizeUuid"/></xsl:variable>
and referred to it at the place that says "VARIABLE" in the above code.
The key thing here is that you need to enclose this reference in curly brackets such as
Code:
<article xml:id="{$uuid}"
xsi:schemaLocation="http://docbook.org/ns/docbook docbook.xsd"
[...]
to force the evaluation of the variable. Without the curly brackets you'd just end up with a string that says "$uuid".

Hope this helps someone in the future.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Namespaces lustigon BOOK: Beginning ASP.NET 4 : in C# and VB 1 October 4th, 2010 02:40 AM
Dynamic namespaces Clemensl XSLT 7 June 17th, 2010 12:01 PM
Namespaces Amateur BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 November 27th, 2006 05:19 PM
namespaces anchal C# 1 July 3rd, 2006 02:53 PM
NAMESPACES - WHAT ARE THEY? p_nut33 C# 2 July 31st, 2003 03:18 AM





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