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

January 15th, 2009, 06:37 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 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: 36
Thanks: 3
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
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 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: 36
Thanks: 3
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
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 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: 36
Thanks: 3
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
Points: 18,059, Level: 58 |
|
|
Join Date: May 2003
Posts: 1,906
Thanks: 62
Thanked 139 Times in 101 Posts
|
|
FYI, you were just getting caught by the spam filter. It's still fine tuning. ;) Your reply is visible now.
__________________
Jim Minatel
Associate Publisher, WROX - A Wiley Brand
Did someone here help you? Click  on their post!
|
|
 |