xsl-list
[Top] [All Lists]

RE: apply-templates with-param failed

2005-09-27 06:48:09
The source document is an output of a static code
analyzer called FindBugs, following is a sample:
<?xml version="1.0" encoding="UTF-8"?>

<BugCollection version="0.9.3" sequence="0"
timestamp="1127452941384" release="">
  <Project filename="&lt;&lt;unnamed project&gt;&gt;">
    <SrcDir>X:\MyServer\classfiles</SrcDir>
  </Project>
  <BugInstance type="DE_MIGHT_IGNORE" priority="2"
abbrev="DE" category="CORRECTNESS" uid="258">
    <ShortMessage>Method might ignore
exception</ShortMessage>
    <LongMessage>DE:
jsp_servlet._en.__notification_alert._jspService(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
might ignore java.lang.Exception</LongMessage>
    <Class
classname="jsp_servlet._en.__notification_alert">
      <Message>In class
jsp_servlet._en.__notification_alert</Message>
    </Class>
    <Method
classname="jsp_servlet._en.__notification_alert"
name="_jspService"
signature="(Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse;)V"
isStatic="false">
      <SourceLine
classname="jsp_servlet._en.__notification_alert"
start="619" end="829" startBytecode="0"
endBytecode="1284" opcodes=""
sourcefile="__notification_alert.java"/>
      <Message>In method
jsp_servlet._en.__notification_alert._jspService(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)</Message>
    </Method>
    <SourceLine classname="" start="147" end="147"
startBytecode="399" endBytecode="399"
opcodes="25,25,25,182,167|58|44,25,18,178,184"
sourcefile="../../com/avinamart/WebInterface/public_html/en/include/notification_head.inc">
      <Message>At __notification_alert.java:[line
687]</Message>
    </SourceLine>
    <Class classname="java.lang.Exception"
role="CLASS_EXCEPTION">
      <Message>Exception class
java.lang.Exception</Message>
    </Class>
  </BugInstance>
  <BugCategory category="PERFORMANCE">
    <Description>Performance</Description>
  </BugCategory>
  <BugCategory category="CORRECTNESS">
    <Description>Correctness</Description>
  </BugCategory>
  <BugCategory category="STYLE">
    <Description>Style</Description>
  </BugCategory>
  <BugPattern type="DE_MIGHT_IGNORE" abbrev="DE"
category="CORRECTNESS">
    <ShortDescription>Method might ignore
exception</ShortDescription>
    <Details><![CDATA[

  <p> This method might ignore an exception.&nbsp; In
general, exceptions
  should be handled or reported in some way, or they
should be thrown
  out of the method.</p>

    ]]></Details>
  </BugPattern>
  <BugCode abbrev="DE">
    <Description>Dropped or ignored
exception</Description>
  </BugCode>
  <Errors></Errors>
  <FindBugsSummary></FindBugsSummary>
  <ClassFeatures></ClassFeatures>
  <History></History>
</BugCollection>

Yesterday, with you and help of the list, I was able
to get the following XSLT work, without the document()
and with-param:

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:fo="http://www.w3.org/1999/XSL/Format";>
        <xsl:template match="/">
                <xsl:call-template name="splitByFunctionalAreas"/>
        </xsl:template>
        <xsl:template name="splitByFunctionalAreas">
                <xsl:result-document href="messaging_bugs.xml">
                        <xsl:apply-templates select="BugCollection"/>
                </xsl:result-document>
        </xsl:template>
        <xsl:template match="BugCollection">
                <!-- element BugCollection has to start on a new
line; otherwise, FindBugs won't load successfully -->
                <xsl:text>&#x9;&#xA;</xsl:text>
                <xsl:element name="BugCollection">
                        <xsl:copy-of select="@*"/>
                        <xsl:text>&#x9;&#xA;</xsl:text>
                        <xsl:copy-of select="Project"/>
                        <xsl:apply-templates select="BugInstance"/>
                        <xsl:copy-of select="BugCategory"/>
                        <xsl:copy-of select="BugPattern"/>
                        <xsl:copy-of select="BugCode"/>
                        <!-- following 3 elements are empty in source XML,
copy anyway -->
                        <xsl:copy-of select="Errors"/>
                        <xsl:copy-of select="ClassFeatures"/>
                        <xsl:copy-of select="History"/>                 
                </xsl:element>
        </xsl:template>
        <xsl:template match="BugInstance">
                <xsl:variable name="vClassName"
select="Class[1]/@classname"/>
                <xsl:if test="contains($vClassName, 'notification')
or contains($vClassName, 'message')">
                        <xsl:copy-of select="."/>
                </xsl:if>
        </xsl:template>
</xsl:stylesheet>

Now I am just trying to extend it to read config from
FunctionalAreaDef.xml and pass on the params, I
encountered apply-templates with-param failed.

Any suggestion would be appreciated, thanks.

Xiaocun

--- Michael Kay <mike(_at_)saxonica(_dot_)com> wrote:

You haven't shown us the source document. Perhaps
its outermost element
isn't called BugCollection, or perhaps it's in a
namespace.

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: Xiaocun Xu [mailto:xiaocunxu(_at_)yahoo(_dot_)com] 
Sent: 27 September 2005 02:08
To: xsl-list
Subject: [xsl] apply-templates with-param failed

Hi,

I am working on splitting a FindBugs result XML
into
multiple XMLs by finding keywords in
Class/@classname.
 Keywords for all functional areas are defined in
FunctionalAreaDef.xml:
<Application>
    <FunctionalArea name="message">
            <Keywords>
                    <Keyword>notification</Keyword>
                    <Keyword>message</Keyword>
            </Keywords>
    </FunctionalArea> ...
</Application>

I use the following XSL to read
FunctionalAreaDef.xml,
loop through each FunctionalArea element, create
an
output file using the FunctioalArea/@name and pass
Keywords to BugCollection element(in the source
FindBugs XML):
<xsl:variable name="vFunctionalArea"
select="document('FunctionalAreaDef.xml')"/>
<xsl:template match="/">
    <xsl:for-each


select="$vFunctionalArea/Application/FunctionalArea">
            <xsl:call-template
name="splitByFunctionalAreas">
                    <xsl:with-param name="pFunctionalAreaDef"
select="."/>
            </xsl:call-template>
    </xsl:for-each>
</xsl:template>
<xsl:template name="splitByFunctionalAreas">
    <xsl:param name="pFunctionalAreaDef" select="."/>
    <xsl:variable name="vFileName"
select="$pFunctionalAreaDef/@name"/>
    <xsl:result-document
href="{$vFileName}_bugs.xml">
            <xsl:apply-templates select="BugCollection">
                    <xsl:with-param name="pKeywords"
select="$pFunctionalAreaDef/Keywords"/>
            </xsl:apply-templates>                  
    </xsl:result-document>
</xsl:template>
<xsl:template match="BugCollection">
    <xsl:param name="pKeywords" select="."/>
    <xsl:value-of select="$pKeywords"/>
    ...
    
Somehow the BugCollection template did not get
evoked
as <xsl:value-of select="$pKeywords"/> seems not
evaluated (the output file is empty with just a
XML
header).  I used matching mode as well, still no
luck.
 Any suggestion on what have I done wrong would be
much appreciated.

thanks,
Xiaocun


            
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.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>
--~--






--~------------------------------------------------------------------
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>
--~--




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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>