|
|
 |
| 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.
|
 |
|

January 15th, 2009, 06:37 AM
|
 |
Wrox Author
Points: 12,735, Level: 48 |
|
|
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,923
Thanks: 0
Thanked 82 Times in 80 Posts
|
|
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
|

January 15th, 2009, 06:51 AM
|
|
Authorized User
|
|
Join Date: Jan 2009
Posts: 23
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
This still does not work is there a way in xslt 2.0 to acheive the expected results ?
|

January 15th, 2009, 06:59 AM
|
 |
Wrox Author
Points: 12,735, Level: 48 |
|
|
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,923
Thanks: 0
Thanked 82 Times in 80 Posts
|
|
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
|

January 15th, 2009, 07:09 AM
|
|
Authorized User
|
|
Join Date: Jan 2009
Posts: 23
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
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
|

January 15th, 2009, 07:32 AM
|
 |
Wrox Author
Points: 12,735, Level: 48 |
|
|
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,923
Thanks: 0
Thanked 82 Times in 80 Posts
|
|
>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
|

January 15th, 2009, 08:17 AM
|
|
Authorized User
|
|
Join Date: Jan 2009
Posts: 23
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
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.
|

January 15th, 2009, 08:18 AM
|
 |
Wrox Staff
|
|
Join Date: May 2003
Location: Indianapolis, IN, USA.
Posts: 1,349
Thanks: 27
Thanked 49 Times in 40 Posts
|
|
FYI, you were just getting caught by the spam filter. It's still fine tuning. ;) Your reply is visible now.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |