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

Re: Re: XSLT help.

Subject: Re: Re: XSLT help.
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Mon, 19 Jun 2006 16:33:50 -0400
xslt xmlns
Karen,

You've been caught by a small, but very consequential, complexity regarding the way XML and XSLT handle names (here, element names). In short, your source document elements are in a namespace, although they appear there without a namespace prefix. In order for you to be able to match them by name, you need to write match patterns using prefixes that refer to the same namespace that they have in the source document.

That is, since your source documents have

xmlns="http://tempuri.org/XMLSchema1.xsd

Your stylesheet should have something like

<xsl:stylesheet ...
  xmlns:t="http://tempuri.org/XMLSchema1.xsd >

<xsl:template match="t:TAX_CASH_FLOW_ANALYSIS/t:TaxCashFlowUnit>
   ...
</xsl:template>

... etc.

Take a look at these tutorials, which elucidate the problem and solution:
http://www.topxml.com/people/bosley/defaultns.asp

http://tutorials.freeskills.com/read/id/304/headline/XSLT+Basics+Part+2+-+A+Word+About+Namespaces

Good luck,
Wendell

At 02:30 PM 6/19/2006, you wrote:
On 6/19/06, Karen Yang <kyang94@xxxxxxxxx> wrote:
Hi,

I'm a newbbie to the XSLT, and am working on a project in C#.NET which
transforms XML to Excel format. So I'm using the XSLT to help the
transformation.

I attached the code that I'm working and the source XML. It's
interesting that when I do the match = tag name, the system won't
recognize this for me. But if I use match="/*/*", which I got from a
website and it worked (the website address is:
http://aspalliance.com/471). So I'm just totally confused, and don't
know where is wrong. I've been stuck here for quite some time, so if
you could help me out, I'd greatly appreciate it.

Thanks a million,

Karen.
It seems the list doesn't allow attachment, then the code comes:

xslt file:

<?xml version='1.0' encoding='utf-8'?>

<xsl:stylesheet version="1.0"
xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:my-scripts"
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:a="http://tempuri.org/XMLSchema1.xsd" exclude-result-prefixes="a
msxsl o ss user x">
<xsl:output method="html"/>

<xsl:template match="/">
        <workbook xmlns:user="urn:my-scripts"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns="urn:schemas-microsoft-com:office:spreadsheet"/>
        <xsl:apply-templates/>
</xsl:template>

<xsl:template match="TAX_CASH_FLOW_ANALYSIS/TaxCashFlowUnit">
 <Worksheet>
 <xsl:attribute name="ss:Name">
 <xsl:value-of select="name(/*/*)"/>
 </xsl:attribute>
<xsl:apply-templates/>
 </Worksheet>
</xsl:template>

<!--<xsl:template match="NoteDetail">
test
<xsl:apply-templates/>
</xsl:template>
-->

<xsl:template match="TAX_CASH_FLOW_ANALYSIS/TaxCashFlowUnit/TaxCashFlowDetail">
<Table x:FullColumns="1" x:FullRows="1">
<Row>
<xsl:for-each select="*[position() = 1]/*">
<Cell><Data ss:Type="String">
<xsl:value-of select="local-name()"/>
</Data></Cell>
</xsl:for-each>
</Row>
<xsl:apply-templates/>
</Table>
</xsl:template>


<xsl:template match="TAX_CASH_FLOW_ANALYSIS/TaxCashFlowUnit/TaxCashFlowDetail">
<Row>
<xsl:apply-templates/>
</Row>
</xsl:template>


<xsl:template match="TAX_CASH_FLOW_ANALYSIS/TaxCashFlowUnit/TaxCashFlowDetail/*">
<Cell><Data ss:Type="String">
<xsl:value-of select="."/>
</Data></Cell>
</xsl:template>



</xsl:stylesheet>



--------------------


xml source file:

<?xml version="1.0" encoding="utf-8"?>
<TAX_CASH_FLOW_ANALYSIS xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
UpdateDateTime="2006-06-13T11:26:09.0000000-04:00"
xmlns="http://tempuri.org/XMLSchema1.xsd">
<TaxCashFlowUnit>
   <TaxCashFlowDetail>
     <EndingAIP>786593727.21233881</EndingAIP>
     <PV>786593727.21233881</PV>
     <PrecapOID>0</PrecapOID>
     <OID>0</OID>
     <RemainingOID>-35744066.285386205</RemainingOID>
     <TaxableIncome>0</TaxableIncome>
     <QtrInt>0</QtrInt>
     <QtrOID>0</QtrOID>
     <QtrIncome>0</QtrIncome>
     <QSI>0</QSI>
     <NQSI>0</NQSI>
     <Principal>0</Principal>
     <CurrentBalance>745850848.91000021</CurrentBalance>
     <MarketDF>0</MarketDF>
   </TaxCashFlowDetail>
   <TaxCashFlowDetail>
     <EndingAIP>786593727.21233881</EndingAIP>
     <PV>786593727.21233881</PV>
     <PrecapOID>0</PrecapOID>
     <OID>0</OID>
     <RemainingOID>-35744066.285386205</RemainingOID>
     <TaxableIncome>0</TaxableIncome>
     <QtrInt>0</QtrInt>
     <QtrOID>0</QtrOID>
     <QtrIncome>0</QtrIncome>
     <QSI>0</QSI>
     <NQSI>0</NQSI>
     <Principal>0</Principal>
     <CurrentBalance>745850848.91000021</CurrentBalance>
     <MarketDF>0</MarketDF>
   </TaxCashFlowDetail>
   <TaxCashFlowDetail>
     <EndingAIP>786593727.21233881</EndingAIP>
     <PV>786593727.21233881</PV>
     <PrecapOID>0</PrecapOID>
     <OID>0</OID>
     <RemainingOID>-35744066.285386205</RemainingOID>
     <TaxableIncome>0</TaxableIncome>
     <QtrInt>0</QtrInt>
     <QtrOID>0</QtrOID>
     <QtrIncome>0</QtrIncome>
     <QSI>0</QSI>
     <NQSI>0</NQSI>
     <Principal>0</Principal>
     <CurrentBalance>745850848.91000021</CurrentBalance>
     <MarketDF>0</MarketDF>
   </TaxCashFlowDetail>
   </TaxCashFlowUnit>
</TAX_CASH_FLOW_ANALYSIS>

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.