xsl-list
[Top] [All Lists]

Re: FW: Newbie question

2004-12-06 11:28:05
Hi David,

That is because your XPath expressions match elements from no namespace while all the elements from your XML file are from http://tempuri.org/test.xsd namespace:

> <CorporateActionAnnouncement xmlns="http://tempuri.org/test.xsd";>

You should add in your stylesheet something like

xmlns:t="http://tempuri.org/test.xsd";

and then use the t prefix to refer to any element in your stylesheet, for instance instead of CorporateActionAnnouncement you should have t:CorporateActionAnnouncement.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


David at roamware wrote:
Hi,

I am new to XSLT. I have been using Treebeard as my editor. I get no errors,
but also no output. I have spent ages looking at the xsl and cannot see what
is wrong. One thing not entirely clear to me is how the context changes,
this is not well epxlained anywhere I have looked. So I tend to use absolute
XPath expressions.

Here is my test.xml

<?xml version="1.0" encoding="iso-8859-1"?>
<CorporateActionAnnouncement xmlns="http://tempuri.org/test.xsd";>
        <AnnouncementDetails>
                <Released>2004-09-27</Released>
        </AnnouncementDetails>
        <Announcement>
                <Title>test</Title>
        </Announcement>
        <CorporateAction>
                <GeneralInformationBlock>
                        <FunctionofMessage>2</FunctionofMessage>
                </GeneralInformationBlock>
                <UnderlyingSecurities>
                        <UnderlyingSecurityISIN>
                                <Listing>PLIS</Listing>
                        </UnderlyingSecurityISIN>
                </UnderlyingSecurities>
                <CorporateActionDetail>
                        <RecordDate>2004-08-20</RecordDate>
                </CorporateActionDetail>
                <CorporateActionOption>
                        
<CorporateActionOptionNumber>001</CorporateActionOptionNumber>
                        <CorporateActionOptionsCode>Securities
Option</CorporateActionOptionsCode>
                        <DefaultProcessingFlag>1</DefaultProcessingFlag>
                        <CashPaymentDetails>
                                <PaymentDate>2004-10-06</PaymentDate>
                        </CashPaymentDetails>
                        <SecuritiesMovement>
                                <DebitCreditIndicator></DebitCreditIndicator>
                        </SecuritiesMovement>
                </CorporateActionOption>
                <CorporateActionOption>
                        
<CorporateActionOptionNumber>002</CorporateActionOptionNumber>
                        <CorporateActionOptionsCode>Securities
Option</CorporateActionOptionsCode>
                        <DefaultProcessingFlag>2</DefaultProcessingFlag>
                        <CashPaymentDetails>
                                <PaymentDate></PaymentDate>
                        </CashPaymentDetails>
                        <SecuritiesMovement>
                                
<DebitCreditIndicator>Credit</DebitCreditIndicator>
                        </SecuritiesMovement>
                </CorporateActionOption>
        </CorporateAction>
</CorporateActionAnnouncement>

Here is my xsl

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
        <xsl:output method="text" indent="no" encoding="ISO-8859-1"/>
        <xsl:template match="/">
<xsl:apply-templates
select="/CorporateActionAnnouncement/CorporateAction/GeneralInformationBlock
"></xsl:apply-templates>
<xsl:apply-templates
select="/CorporateActionAnnouncement/CorporateAction/UnderlyingSecurities"><
/xsl:apply-templates>
<xsl:apply-templates
select="/CorporateActionAnnouncement/CorporateAction/CorporateActionDetail">
</xsl:apply-templates>
<xsl:apply-templates
select="/CorporateActionAnnouncement/CorporateAction/CorporateActionOption">
</xsl:apply-templates>
        </xsl:template>

        <xsl:template match="GeneralInformationBlock">
testoutput<xsl:call-template name="funcmsglookup"><xsl:with-param
name="codef" select="FunctionofMessage"/></xsl:call-template>
moretestoutput
        </xsl:template>

        <xsl:template match="UnderlyingSecurities">
/<xsl:value-of select="UnderlyingSecurityISIN/Listing"/>/
        </xsl:template>

        <xsl:template match="CorporateActionDetail">
test//<xsl:call-template name="dateformat"><xsl:with-param name="adate"
select="RecordDate"/></xsl:call-template>
        </xsl:template>

        <xsl:template match="CorporateActionOption">
//<xsl:value-of select="CorporateActionOptionNumber"/>
OP//<xsl:call-template name="caoptlookup"><xsl:with-param name="codea"
select="CorporateActionOptionsCode"/></xsl:call-template>
LT//<xsl:call-template name="defproclookup"><xsl:with-param name="codep"
select="DefaultProcessingFlag"/></xsl:call-template>
        <xsl:if test="CashPaymentDetails!=''">
YD//<xsl:value-of select="DefaultProcessingFlag"/>
S//<xsl:value-of
select="CashPaymentDetails/GrossAmountPayable/Currency"/><xsl:value-of
select="CashPaymentDetails/GrossAmountPayable/Currency"/>
        </xsl:if>
        <xsl:if test="SecuritiesMovement!=''">
B//<xsl:call-template name="debcredlookup"><xsl:with-param name="codee"
select="DebitCreditIndicator"/></xsl:call-template>
MOVE
        </xsl:if>
MOREOUT
        </xsl:template>

        <xsl:template name="funcmsglookup">
                <xsl:param name="codef"/>
                <xsl:if test="codef=0"><xsl:text></xsl:text>NEWM</xsl:if>
                <xsl:if test="codef=1"><xsl:text>REPL</xsl:text></xsl:if>
                <xsl:if test="codef=2"><xsl:text>CANC</xsl:text></xsl:if>
        </xsl:template>

        <xsl:template name="caoptlookup">
                <xsl:param name="codea"/>
                <xsl:if test="codea=0"></xsl:if>
                <xsl:if test="codea=1"><xsl:text>CASH</xsl:text></xsl:if>
                <xsl:if test="codea=2"><xsl:text>SECU</xsl:text></xsl:if>
        </xsl:template>

        <xsl:template name="debcredlookup">
                <xsl:param name="codee"/>
                <xsl:if test="codee=0"></xsl:if>
                <xsl:if test="codee=1"><xsl:text>CRED</xsl:text></xsl:if>
                <xsl:if test="codee=2"><xsl:text>DEBT</xsl:text></xsl:if>
        </xsl:template>

        <xsl:template name="defproclookup">
                <xsl:param name="codep"/>
                <xsl:if test="codep=0"></xsl:if>
                <xsl:if test="codep=1"><xsl:text>Y</xsl:text></xsl:if>
                <xsl:if test="codep=2"><xsl:text>N</xsl:text></xsl:if>
        </xsl:template>

        <xsl:template name="dateformat">
                <xsl:param name="adate"/>

<xsl:text>substring($adate,0,4)substring($adate,5,2)substring($adate,8,2)</x
sl:text>
        </xsl:template>
</xsl:stylesheet>

where am I going wrong?

Thx.

David


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>