[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: FW: Problem with namespaces

Subject: Re: FW: Problem with namespaces
From: "Jay Bryant" <jay@xxxxxxxxxxxx>
Date: Fri, 5 Aug 2005 12:53:42 -0500
ss workbook
Sorry to reply to my own message. I want to clarify the issue, lest someone
reading the archives get the wrong impression.

In a private message, Curtis pointed out that he had mapped the default
namespace to "ss". I had missed that, as I wasn't looking closely enough at
the namespaces. So the issue was knowing to use the "ss" namespace in the
XSL file to handle the default namespace in the source file. Here is the
corrected stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<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"
  exclude-result-prefixes="o x ss"
>

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

  <xsl:template match="ss:Workbook/ss:Worksheet/ss:Table/ss:Row[1]"/>

  <xsl:template match="ss:Workbook/ss:Worksheet/ss:Table/ss:Row[position()
&gt; 1]">
    <Inventory>
      <xsl:for-each select="ss:Cell">
        <xsl:choose>
          <xsl:when test="position() = 1">
            <Year><xsl:value-of select="ss:Data"/></Year>
          </xsl:when>
          <xsl:when test="position() = 2">
            <Make><xsl:value-of select="ss:Data"/></Make>
          </xsl:when>
          <xsl:when test="position() = 3">
            <Model><xsl:value-of select="ss:Data"/></Model>
          </xsl:when>
        </xsl:choose>
      </xsl:for-each>
    </Inventory>
  </xsl:template>

</xsl:stylesheet>

Thanks for your patience.

Jay Bryant
Bryant Communication Services

----- Original Message ----- 
From: <JBryant@xxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, August 04, 2005 2:27 PM
Subject: Re:  FW: Problem with namespaces


> Hi, Curtis,
>
> Your issue arises because the XML file has a default namespace:
>
> xmlns="urn:schemas-microsoft-com:office:spreadsheet"
>
> You need to handle that in your XSL file, thus:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>   xmlns:ms="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"
>   exclude-result-prefixes="ms o x ss"
> >
>
>   <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
>
>   <xsl:template match="ms:Workbook/ms:Worksheet/ms:Table/ms:Row[1]"/>
>
>   <xsl:template match="ms:Workbook/ms:Worksheet/ms:Table/ms:Row[position()
> &gt; 1]">
>     <Inventory>
>       <xsl:for-each select="ms:Cell">
>         <xsl:choose>
>           <xsl:when test="position() = 1">
>             <Year><xsl:value-of select="ms:Data"/></Year>
>           </xsl:when>
>           <xsl:when test="position() = 2">
>             <Make><xsl:value-of select="ms:Data"/></Make>
>           </xsl:when>
>           <xsl:when test="position() = 3">
>             <Model><xsl:value-of select="ms:Data"/></Model>
>           </xsl:when>
>         </xsl:choose>
>       </xsl:for-each>
>     </Inventory>
>   </xsl:template>
>
> </xsl:stylesheet>
>
> As you can see, I greatly simplified your file, but I bet you can make
> sense of it.
>
> In addition to the simplifications, the specific changes that matter to
> this issue are:
>
> * I gave the default namespace an identifier (ms).
> * I used that identifier in all the matches and selects.
>
> The output (with Xalan Java 2.4.1, since you need XSLT 1.0) is:
>
> <Inventory>
>   <Year>2000</Year>
>   <Make>Buick</Make>
>   <Model>Park Ave</Model>
> </Inventory>
> <Inventory>
>   <Year>1998</Year>
>   <Make>Cadillac</Make>
>   <Model>Deville</Model>
> </Inventory>
> <Inventory>
>   <Year>1995</Year>
>   <Make>Cadillac</Make>
>   <Model>Deville</Model>
> </Inventory>
>
> (with a little hand indenting for readiblity)
>
> Saxon 8.5 produces the same results (indentation aside).
>
> Let us know if you need more help. Feel free to use me as a proxy for
> posting if need be.
>
> Jay Bryant
> Bryant Communication Services
> (presently consulting at Synergistic Solution Technologies)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.