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

RE: XSLT call-template question

  • From: "Cintron, Jose J." <jcintron@m...>
  • To: <joe@r...>, <xml-dev@l...>
  • Date: Thu, 9 Nov 2006 12:33:27 -0500

mitre corporation
Thanks for the suggestion it worked great! 



+------------------------------------------
| José J. Cintrón - <jcintron@m...>
|
| MITRE Corporation
| 7515 Colshire Drive
| Mail Stop T330
| McLean, VA  22102-7508
|
| Phone: 703.983.3040
| Fax: 703.983.1397
+------------------------------------------
-----Original Message-----
From: Joe Fawcett [mailto:joefawcett@h...] 
Sent: Thursday, November 09, 2006 12:24
To: xml-dev@l...
Cc: Cintron, Jose J.
Subject: RE:  XSLT call-template question

Jose

You rarely need the match on a xsl:template to start with //. So you can
change:
<xsl:template match="//imp:FINDING[imp:FINDING_STATUS='O'"> to <xsl:template
match="imp:FINDING[imp:FINDING_STATUS='O'">
(Not sure you need the predicate either but I don't know the whole code) An
obsession with using //in XPath expressions seems all too common, not sure
why, perhaps there are a lot of poor examples online :) If you want the
<FINDING_ID> element in the <xsl:template name="FINDING_DETAILS"> then you
could pass it in:
   <xsl:call-template name="FINDING_DETAILS">
    <xsl:with-param name="FID" select="imp:FINDING_ID"/>

then:
  <xsl:template name="FINDING_DETAILS">
    <xsl:param name="FID"/>

>From: "Cintron, Jose J." <jcintron@m...>
>To: <xml-dev@l...>
>Subject:  XSLT call-template question
>Date: Thu, 9 Nov 2006 11:56:50 -0500
>
>I have an XML doc and XSLT that look that looks like the following 
>samples.  What I want to do is to pull the description of the 
>vulnerability from a separate document.  The problem is that when I 
>call the FINDING_DETAILS template for some reason I cannot access the 
>FINDING_ID of the FINDING that I'm currently processing.  I tried, just 
>to see what I got <xsl:variable name="FID"><xsl:value-of 
>select="self::*"/><xsl:value-of select="$FID"/> and what I got was the 
>whole finding that I'm processing.  That said.  How the heck do I 
>select the FINDING_ID item so that I can assign that value to the 
>variable and then I use this to pull the correct description from the 
>external document.
>
>--- BEGIN XML ---
><?xml version="1.0" encoding="UTF-8"?>
><?xml-stylesheet type='text/xsl' href='DCID_Open.xslt'?> <IMPORT_FILE 
>xmlns="urn:FindingImport"
>xmlns:xi="http://www.w3.org/2001/XInclude/">
>    <FINDING>
>       <FINDING_ID>V0006670</FINDING_ID>
>       <FINDING_STATUS>NR</FINDING_STATUS>
>       <VUL_NAME>Mechanism in place for key recovery</VUL_NAME>
>       <SEVERITY>3</SEVERITY>
>    </FINDING>
>    .
>    Repate this many, many times
>    .
></IMPORT_FILE>
>--- END XML ---
>
>--- BEGIN XSLT ---
><?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0"
>xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>xmlns:imp="urn:FindingImport">
><xsl:template match="/">
>    <HTML>
>    <HEAD>
>          <TITLE>Findings Report</TITLE>
>    </HEAD>
>    <BODY style="font-family: sans-serif">
>    <h3Findings:</h3>
>       <xsl:apply-templates
>select="//imp:FINDING[imp:FINDING_STATUS='O'">
>          <xsl:sort select="imp:SEVERITY" order="ascending"
>data-type="number" />
>          <xsl:sort select="imp:FINDING_ID" order="ascending"
>data-type="text" />
>       </xsl:apply-templates>
>    </BODY>
>    </HTML>
></xsl:template>
>
><xsl:template match="//imp:FINDING[imp:FINDING_STATUS='O'">
>    <dl>
>       <table>
>          <tr>
>             <td>
>                <table>
>                   <tr>
>                      <td><xsl:apply-templates select="imp:SEVERITY" /> 
></td>
>                      <td><xsl:apply-templates select="imp:FINDING_ID"
>/> </td>
>                   </tr>
>                   <tr>
>                      <td colspan="2"><xsl:apply-templates 
>select="imp:VUL_NAME" /></td>
>                   </tr>
>                </table>
>             </td>
>          </tr>
>          <tr><td><xsl:call-template name="FINDING_DETAILS" /></td></tr>
>          <tr><td><xsl:apply-templates select="imp:SCRIPT_RESULTS"
>/></td></tr>
>          <tr><td><xsl:call-template name="TEST" /></td></tr>
>       </table>
>    </dl>
></xsl:template>
><xsl:template name="FINDING_DETAILS">
>    <dd><b><SPAN STYLE="font-style:italic">Details:</SPAN></b></dd>
>    <dd>
>       <xsl:variable name="FID"><xsl:value-of 
>select="..//imp:FINDING_ID/text()"/>
>       <xsl:value-of
>select="document('BaseVulns.xml')//VULNERABILITIES/VULNERABILITY[V_6X=$
>FID]/DESCRIPTION" />
>    </dd>
></xsl:template>
>.
>Just ignore the rest of the templates they work just fine...
>.
></xsl:stylesheet>
>--- END XSLT ---
>
>
>+------------------------------------------
>| José J. Cintrón - <jcintron@m...>
>|
>| MITRE Corporation
>| 7515 Colshire Drive
>| Mail Stop T330
>| McLean, VA  22102-7508
>|
>| Phone: 703.983.3040
>| Fax: 703.983.1397
>+------------------------------------------
>
>_______________________________________________________________________
>
>XML-DEV is a publicly archived, unmoderated list hosted by OASIS to 
>support XML implementation and development. To minimize spam in the 
>archives, you must subscribe before posting.
>
>[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
>Or unsubscribe: xml-dev-unsubscribe@l...
>subscribe: xml-dev-subscribe@l... List archive: 
>http://lists.xml.org/archives/xml-dev/
>List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
>


smime.p7s



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.