p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > XML > XSLT
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old January 15th, 2009, 06:37 AM
mhkay's Avatar
Wrox Author
Points: 12,735, Level: 48
Points: 12,735, Level: 48 Points: 12,735, Level: 48 Points: 12,735, Level: 48
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,923
Thanks: 0
Thanked 82 Times in 80 Posts
Default

XSLT 1.0 doesn't give you a guaranteed way to get a particular prefix in the output but most processors will retain the prefix you use in the name attribute if possible, e.g.

<xsl:element name="icns:{local-name()}" namespace="{.....}">
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #12 (permalink)  
Old January 15th, 2009, 06:51 AM
Authorized User
Points: 95, Level: 1
Points: 95, Level: 1 Points: 95, Level: 1 Points: 95, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2009
Posts: 23
Thanks: 2
Thanked 0 Times in 0 Posts
Default

This still does not work is there a way in xslt 2.0 to acheive the expected results ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #13 (permalink)  
Old January 15th, 2009, 06:59 AM
mhkay's Avatar
Wrox Author
Points: 12,735, Level: 48
Points: 12,735, Level: 48 Points: 12,735, Level: 48 Points: 12,735, Level: 48
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,923
Thanks: 0
Thanked 82 Times in 80 Posts
Default

Please don't say "it doesn't work" -that's useless information. Tell us exactly what you did and exactly how it failed, and then we can tell you what you did wrong.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #14 (permalink)  
Old January 15th, 2009, 07:09 AM
Authorized User
Points: 95, Level: 1
Points: 95, Level: 1 Points: 95, Level: 1 Points: 95, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2009
Posts: 23
Thanks: 2
Thanked 0 Times in 0 Posts
Default

When i use
<xsl:element name="icns:{local-name()}" namespace="urn:Test">

the resulting xml is prefixed with icns in every node.
<icns:Print_Data xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:icns="urn:Test"
<icns:....></icns:....>
</icns:Print_Data>

i'm using built in Altova XML spy xsl parser
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #15 (permalink)  
Old January 15th, 2009, 07:32 AM
mhkay's Avatar
Wrox Author
Points: 12,735, Level: 48
Points: 12,735, Level: 48 Points: 12,735, Level: 48 Points: 12,735, Level: 48
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,923
Thanks: 0
Thanked 82 Times in 80 Posts
Default

>When i use
> <xsl:element name="icns:{local-name()}" namespace="urn:Test">

>the resulting xml is prefixed with icns in every node.

So it does work - when you said it doesn't work, you were misleading us.

If you only want some nodes to use this prefix, then only use this construct on those nodes.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #16 (permalink)  
Old January 15th, 2009, 08:17 AM
Authorized User
Points: 95, Level: 1
Points: 95, Level: 1 Points: 95, Level: 1 Points: 95, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2009
Posts: 23
Thanks: 2
Thanked 0 Times in 0 Posts
Default

Sorry for not being very clear.

Here's my input xml
<Print_Data xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc
="http://schemas.xmlsoap.org/soap/encoding/"xmlns:icns="urn:NewBusiness_ATV"</Print_Data>

here's the xsl i'm using
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"
xmlns:soapenv
="http://schemas.xmlsoap.org/soap/envelope/"xmlns:icns="urn:NewBusiness_ATV">

<xsl:template match="/">
<soapenv:Envelope>
<soapenv:Header>
<icns:IplusHeader>
<icns:freeFormatText>
Sample Text
</icns:freeFormatText>
</icns:IplusHeader>
</soapenv:Header>
</soapenv:Envelope>
</xsl:template>

<xsl:template match="@* | text() | comment() | processing-instruction()">
<xsl:copy/>
</xsl:template>

<xsl:template match="*">
<xsl:element name="{name()}" namespace="urn:TEST">
<xsl:copy-of select="document('')/xsl:stylesheet/namespace::*[local-name() = 'icns']"/>
<xsl:copy-of select="namespace::*[not(local-name() = 'icns')]"/>
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>

I'm expecting the following result xml
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd
="http://www.w3.org/2001/XMLSchema"
xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance">
<
soapenv:Header>
<
icns:IplusHeader xmlns:icns="urn:TEST">
<
icns:freeFormatText>
Sample Text
</icns:freeFormatText>
</
icns:IplusHeader>
</
soapenv:Header>
</
soapenv:Envelope>

Last edited by nguna : January 15th, 2009 at 08:22 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #17 (permalink)  
Old January 15th, 2009, 08:18 AM
jminatel's Avatar
Wrox Staff
Points: 7,285, Level: 36
Points: 7,285, Level: 36 Points: 7,285, Level: 36 Points: 7,285, Level: 36
Activity: 17%
Activity: 17% Activity: 17% Activity: 17%
 
Join Date: May 2003
Location: Indianapolis, IN, USA.
Posts: 1,349
Thanks: 27
Thanked 49 Times in 40 Posts
Default

FYI, you were just getting caught by the spam filter. It's still fine tuning. ;) Your reply is visible now.
__________________
Jim Minatel
Associate Publisher
Wiley Technology Publishing
WROX Press
Blog: http://p2p.wrox.com/content/blogs/jminatel
Wrox online library: http://wrox.books24x7.com
Wrox on Twitter: http://twitter.com/wrox
Did someone here help you? Click on their post!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is ".Namespace" ?! Employee C# 2 May 14th, 2008 11:55 AM
namespace Tomi XML 0 September 14th, 2007 05:39 AM
Namespace help CamosunStudent BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 October 6th, 2006 05:12 PM
change namespace leaving prefix unchanged lantoli XSLT 3 June 26th, 2006 08:31 AM
How can I change the default namespace allanhu BOOK: ASP.NET Website Programming Problem-Design-Solution 1 November 1st, 2004 01:15 PM



All times are GMT -4. The time now is 04:23 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc