All my declared namespaces are showing up in my <br/>

Here should go questions about transforming XML with XSLT and FOP.
mphare
Posts: 71
Joined: Fri Apr 30, 2004 8:00 pm
Location: Texas

All my declared namespaces are showing up in my <br/>

Post by mphare » Sat Feb 18, 2006 1:16 am

I'm using Saxon 8.1B and Oxygen v5 (I'll be upgrading this evening to v7)
When I translate a namespace aware XML file using my stylesheet, I get all the namespaces repeated in the <BR/> html tags. They also show up in other tags (like <p>)

Here's my XSL fragment so far..

Code: Select all

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet"
xpath-default-namespace="urn:schemas-microsoft-com:office:spreadsheet">
<!--
****************************************************
-->
<!-- Begin Output Processing -->

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/Workbook">
<xsl:apply-templates select="Worksheet"></xsl:apply-templates>
</xsl:template>
<!--
****************************************************
Template for element Worksheet
****************************************************
-->
<xsl:template match="Worksheet">
<br/><xsl:text> In the Template for Worksheet processing</xsl:text>
<xsl:apply-templates select="Table/Row"></xsl:apply-templates>
</xsl:template>
... more templates down here ...
Here's my output

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<br xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet"/> In the Template for Worksheet processing[In the Template for Row processing][Cell Index Value: 6][In the Template for Row processing][Cell Index Value: ][Data Value: Chapter 1][Cell Index Value: 5][Data Value: Y][Cell Index Value: ][Data Value: Describe this Chapter][In the Template for Row processing][Cell Index Value: 2][Data Value: Req 1][Cell Index Value: 5][Data Value: Y][Cell Index Value: ][Data Value: Describe Req 1 here][In the Template for Row processing][Cell Index Value: 2][Data Value: Req 2][Cell Index Value: 5][Data Value: Y][Cell Index Value: ][Data Value: Describe Req 2 here][In the Template for Row processing][Cell Index Value: 3][Data Value: Req 2.1][Cell Index Value: 5][Data Value: Y][Cell Index Value: ][Data Value: Describe Req 2.1 here][In the Template for Row processing][Cell Index Value: 2][Data Value: Req 3][Cell Index Value: 5][Data Value: Y][Cell Index Value: 6][In the Template for Row processing][Cell Index Value: 3][Data Value: Req 3.1][Cell Index Value: 5][Data Value: Y][Cell Index Value: 6][In the Template for Row processing][Cell Index Value: 3][Data Value: Req 3.2][Cell Index Value: 5][Data Value: N][Cell Index Value: 6][In the Template for Row processing][Cell Index Value: 3][Data Value: Req 3.3][Cell Index Value: 5][Data Value: N][Cell Index Value: 6][In the Template for Row processing][Cell Index Value: 4][Data Value: Req 3.3.1][Cell Index Value: ][Data Value: Y][Cell Index Value: 6][In the Template for Row processing][Cell Index Value: 4][Data Value: Req 3.3.2][Cell Index Value: ][Data Value: N][Cell Index Value: 6][In the Template for Row processing][Cell Index Value: 3][Data Value: Req 3.4][Cell Index Value: 5][Data Value: Y][Cell Index Value: 6][In the Template for Row processing][Cell Index Value: 4][Data Value: Req 3.4.1][Cell Index Value: ][Data Value: Y][Cell Index Value: 6][In the Template for Row processing][Cell Index Value: 2][Data Value: Req 4][Cell Index Value: 5][Data Value: Y][Cell Index Value: 6][In the Template for Row processing][Cell Index Value: 2][Data Value: Req 5][Cell Index Value: 5][Data Value: Y][Cell Index Value: 6]<br xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet"/> In the Template for Worksheet processing[In the Template for Row processing][Cell Index Value: 1]<br xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet"/> In the Template for Worksheet processing[In the Template for Row processing][Cell Index Value: 1]
Why would the namespaces be repeated within the <BR/> tag?

-: confused :-
--------------------------

- mike

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

mphare
Posts: 71
Joined: Fri Apr 30, 2004 8:00 pm
Location: Texas

Post by mphare » Mon Feb 20, 2006 6:20 pm

I still have thir propblem after upgrading to v.7. I guess I was hoping a newer version of Saxon would fix the problem.

Since it didn't, and I can't believe this is a widespread problem, I must assume I've done something wrong in my XSLT file.

If anyone has any thought, PLEASE let me know.

Thanks,
--------------------------

- mike

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

sorin_ristache
Posts: 4144
Joined: Fri Mar 28, 2003 2:12 pm

Re: All my declared namespaces are showing up in my <br/&

Post by sorin_ristache » Mon Feb 20, 2006 6:33 pm

mphare wrote:Why would the namespaces be repeated within the <BR/> tag?
Because you did not specify what namespaces you don't want in the output, by adding the attribute

Code: Select all

exclude-result-prefixes="xsi x x2 ss o html c"
to the root element <xsl:stylesheet or to specific xsl:template instructions.

Regards,
Sorin

sorin_ristache
Posts: 4144
Joined: Fri Mar 28, 2003 2:12 pm

Post by sorin_ristache » Mon Feb 20, 2006 6:36 pm

Hello,
mphare wrote:I still have thir propblem after upgrading to v.7. I guess I was hoping a newer version of Saxon would fix the problem.
It is an FAQ. The exclude-result-prefixes attribute is required to be implemented by any XSLT 1.0 processor, so early versions of Saxon 6.5 and Saxon 8 implement it correctly.

Regards,
Sorin

mphare
Posts: 71
Joined: Fri Apr 30, 2004 8:00 pm
Location: Texas

Post by mphare » Mon Feb 20, 2006 7:23 pm

I've tried to pair this down as far as I can.

I'm using Oxy7 with Saxon 8B

Here's the original XML document:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?><?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<Cell>Inside the Cell 1</Cell>
<Cell>Inside the Cell 2</Cell>
</Workbook>
Here's the XSLT:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xpath-default-namespace="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!--
****************************************************
-->
<!-- Begin Output Processing -->

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/Workbook">
<xsl:text>Found Workbook</xsl:text>
<xsl:apply-templates select="Cell"></xsl:apply-templates>
</xsl:template>

<!--
****************************************************
Template for Cell
****************************************************
-->
<xsl:template match="Cell">
<br/><xsl:text>Inside the Cell</xsl:text>
</xsl:template>


</xsl:stylesheet>
And here's the output:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>Found Workbook<br xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>Inside the Cell<br xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>Inside the Cell
Notice the xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" inserted in the <br/> tags as <brxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>

What's up with that?
--------------------------

- mike

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

mphare
Posts: 71
Joined: Fri Apr 30, 2004 8:00 pm
Location: Texas

Post by mphare » Mon Feb 20, 2006 7:40 pm

Sorry, missed your response..

Let me check that out.

Thanks!
--------------------------

- mike

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

mphare
Posts: 71
Joined: Fri Apr 30, 2004 8:00 pm
Location: Texas

Post by mphare » Mon Feb 20, 2006 7:54 pm

That did it.

Thanks sorin.
--------------------------

- mike

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

Post Reply