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 September 12th, 2006, 10:25 AM
Registered User
 
Join Date: Sep 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Namespace disappears on transformation

I'm converting XML to an Excel format using XSL. When I run this on localhost, everything works fine. Then, on my server this is what happens:

<Data ss:Type="String">Hello</Data>

gets turned into

<Data Type="String">Hello</Data>

The ss: is getting stripped, which then breaks the export. Both localhost and the server appear to have the same XSL settings. They are running PHP and Apache on Linux. I don't know if this is a server setting or a code problem - i'm not quite sure where to look or what terminology to search for. Any help is appreciated greatly.
 
Old September 12th, 2006, 11:24 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You say that (A) "gets turned into" (B), but you don't make it clear what process is taking place that modifies the file incorrectly. You need to find out what is changing the attribute name, and fix it.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old September 12th, 2006, 11:34 AM
Registered User
 
Join Date: Sep 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just a normal transformation with PHP. The following works fine on localhost:
Code:
$doc = new DOMDocument('1.0', 'utf-8');
$xsheet = new DOMDocument();
$xsl = new XSLTProcessor();

$doc->loadXML($xml);
$xsheet->load('excel-format.xsl');

$xsl->importStyleSheet($xsheet);
echo $xsl->transformToXML($doc);
In the example above, $xml is a valid XML string.
 
Old September 12th, 2006, 11:38 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Line 14 of your stylesheet could be causing problems.

http://p2p.wrox.com/topic.asp?TOPIC_ID=49630

--

Joe (Microsoft MVP - XML)
 
Old September 12th, 2006, 11:43 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You're guessing wildly Joe, I bet it's really line 49.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old September 12th, 2006, 11:48 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

My best guess is that the stylesheet is pulling in some external file that isn't available from the live system, maybe due to permissions or an incorrectly specified URI, although I can't think of any specific scenario that would lead to the particular problem.

--

Joe (Microsoft MVP - XML)
 
Old September 12th, 2006, 12:00 PM
Registered User
 
Join Date: Sep 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry about that. Since everything worked as intended on localhost, I didn't feel that posting the actual XSL would lead to anything. I have tried every possible combination of namespaces/setups found online, and everything works locally. The current setup is:
Code:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">

<xsl:template match="/">

<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
And then the rest of the file ...

I've tried every combination of the above from ss:Workbook to full declarations. Everything works locally, which is why I originally thought it may be a server setting that I am unfamiliar with. Another interesting thing is that only ss: gets stripped. x: remains as it should, and the rest of the output is correct.

Thanks again for looking into this.

 
Old September 13th, 2006, 01:30 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Again without seeing the whole XML input, XSLT and result I've little idea but my guess is that the output is actually well formed, it's just that one uses a default namespace declaration and one doesn't, maybe a different version of the XSLT processor of a different config, I'm not familiar with the PHP XML library.

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
menu disappears in ie 6 bala4601 CSS Cascading Style Sheets 0 March 3rd, 2008 02:22 AM
Properties window disappears. bachakhan VS.NET 2002/2003 1 December 29th, 2004 01:28 PM
AMPERSAND disappears when given along with # happygv Forum and Wrox.com Feedback 2 October 25th, 2004 09:49 PM
CSS disappears on postback byron ASP.NET 1.0 and 1.1 Basics 1 November 12th, 2003 05:18 PM
Value Disappears byron VB.NET 2002/2003 Basics 0 October 13th, 2003 10:19 AM





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