#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    16
    Rep Power
    0

    What is wrong with my node-set() usage?


    I am using VS2012 to produce some html out put. I cannot get the getXMLData template to work. Below is the xsl and xml:

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="http://niem.gov/niem/appinfo/2.0" xmlns:ns2="http://niem.gov/niem/structures/2.0" xmlns:ns3="https://collect.prodcjis.ct.gov/ctsp/ext/1.0" xmlns:ns4="https://collect.prodcjis.ct.gov/ctsp/ncic/1.0" xmlns:ns5="https://collect.prodcjis.ct.gov/ctsp/queries/1.0" xmlns:ns6="https://collect.prodcjis.ct.gov/ctsp/messages/1.0" xmlns:ns7="https://collect.prodcjis.ct.gov/ctsp/NLETS/1.0" xmlns:cjis="http://cjis.fbi.gov/1.0.0" xmlns:jxdm="http://www.it.ojp.gov/jxdm/3.0.3" xmlns:ncic="http://cjis.fbi.gov/ncic/1.0.5" xmlns:n-veh="http://cjis.fbi.gov/ncic/1.0.5/vehicle" xmlns:n-vbp="http://cjis.fbi.gov/ncic/1.0.5/vehicleboatpart" xmlns:n-boa="http://cjis.fbi.gov/ncic/1.0.5/boat" xmlns:n-lic="http://cjis.fbi.gov/ncic/1.0.5/licenseplate" xmlns:n-ide="http://cjis.fbi.gov/ncic/1.0.5/identitytheft" xmlns:n-sex="http://cjis.fbi.gov/ncic/1.0.5/sexualoffender" xmlns:n-vgt="http://cjis.fbi.gov/ncic/1.0.5/vgtof" xmlns:n-pif="http://cjis.fbi.gov/ncic/1.0.5/protectiveinterest" xmlns:n-sup="http://cjis.fbi.gov/ncic/1.0.5/supervisedrelease" xmlns:n-sen="http://cjis.fbi.gov/ncic/1.0.5/sentry" xmlns:n-mis="http://cjis.fbi.gov/ncic/1.0.5/missingperson" xmlns:n-wan="http://cjis.fbi.gov/ncic/1.0.5/wantedperson" xmlns:n-pro="http://cjis.fbi.gov/ncic/1.0.5/protectionorder" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
       <xsl:preserve-space elements="ns5:MessageResponse"/>
      <xsl:output method="html"/>
      
      <!-- the getXML portion was brought in from the ncic provided xslt. Becareful when changing single quotes for database storage especially: initStr -->
      <xsl:template match="ns5:CorrelatedMessageResponse">
        <html>
          <head>
            <link rel="stylesheet" type="text/css" href="cad://content/ui_jqgrid"/>
            <link rel="stylesheet" id="Link1" type="text/css" href="cad://content/redmond"/>
            <script src="cad://content/jquery_1_9_0_min" type="text/javascript"></script>
            <script src="cad://content/jquery_ui_1_10_2_custom" type="text/javascript"></script>
            <script src="cad://content/grid_locale_en" type="text/javascript"></script>
            <script src="cad://content/jquery_jqgrid_min" type="text/javascript"></script>
            <script type="text/javascript" src="cad://content/tabbed_layout"></script>
            <!-- CAD_corr_reply_v2.0 -->
            <style>
               .corrTextReply{font-family:"Courier New"}
               body {background-color:#dfeffc}
            </style>
          </head>
          <body class="corrTextReply">
            <xsl:choose>
               <xsl:when test="ns5:ErrorInfoSection">
                   <xsl:call-template name="GetErrors"/>
                </xsl:when>
               <xsl:when test="ns5:MessageResponse">
                     <xsl:call-template name="GetReply"/>
                </xsl:when>
            </xsl:choose>
          </body>
        </html>
      </xsl:template>
      
     <xsl:template name="GetReply">
        <xsl:choose>
            <xsl:when test="ns3:ResponseFormat='TEXT'">
                <xsl:call-template name="GetText"/>
            </xsl:when>
          <xsl:when test="ns3:ResponseFormat='XML'">
            <xsl:variable name="betterxml">
              <xsl:value-of select ="ns5:MessageResponse" disable-output-escaping="yes"/>
            </xsl:variable>
            <xsl:call-template name="getXMLData">
              <xsl:with-param name="newxml" select="$betterxml"/>
            </xsl:call-template>
            
            </xsl:when>
      </xsl:choose>
    </xsl:template>
        
     <xsl:template name="GetText">
        <xsl:variable name="tmp2">
          <xsl:call-template name="string-replace-all">
            <xsl:with-param name="text" select="ns5:MessageResponse"/>
            <xsl:with-param name="replace" select="' '" />
            <xsl:with-param name="by" select="'SPACE'" />
          </xsl:call-template>
        </xsl:variable>
       
        <xsl:variable name="tmp1">
          <xsl:call-template name="string-replace-all">
            <xsl:with-param name="text" select="$tmp2"/>
            <xsl:with-param name="replace" select="'&#xD;'" />
            <xsl:with-param name="by" select="'EOL'" />
       </xsl:call-template>
       </xsl:variable>
    
        <xsl:copy-of select="$tmp1"/>
      
    </xsl:template>
      
      <xsl:template name="GetErrors">
           
         <xsl:if test="ns5:ErrorInfoSection">
             <table id="tblErrors" cellspacing="0px" style="width:650; border:2px solid #5c9ccc;position:absolute;left:50;margin-top 5px">
             <tr>
                 <th colspan="2" style="width:100%;color: #ffffff;background-color:#32576B">Field Errors</th>
             </tr>
           <xsl:for-each select="ns5:ErrorInfoSection/ns3:Errors">
             <xsl:if test="position() &gt; 1">
               <tr>
                  <th colspan="2" style="height:10px;width:100%;background-color:#5c9ccc"> </th>
             </tr>
             </xsl:if>
    
               <tr><td style="width:20%;border:1px solid black">Field</td><td style="width:90%;border:1px solid black"><xsl:value-of select="ns3:ErrorOnField"/></td></tr>
               <tr><td style="width:20%;border:1px solid black;outline-color:green">Error</td><td  style="width:90%;border:1px solid black"><xsl:value-of select ="ns3:ErrorMessage"/></td></tr>
               <tr><td style="width:20%;border:1px solid black">FixTip</td><td  style="width:90%;border:1px solid black"><xsl:value-of select ="ns3:ErrorFixTip"/></td></tr>
           </xsl:for-each>
         </table>
       </xsl:if>
     </xsl:template>
      
       
       
      <xsl:template name="string-replace-all">
        <xsl:param name="text" />
        <xsl:param name="replace" />
        <xsl:param name="by" />
        <xsl:choose>
          <xsl:when test="contains($text, $replace)">
            <xsl:value-of select="substring-before($text,$replace)" />
            <xsl:choose>
              <xsl:when test="$by='SPACE'">
                 <xsl:text>*</xsl:text>
              </xsl:when>
              <xsl:when test="$by='EOL'">
                  <br/>
              </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="$by" />
            </xsl:otherwise>
              </xsl:choose>
            <xsl:call-template name="string-replace-all">
              <xsl:with-param name="text"
              select="substring-after($text,$replace)" />
              <xsl:with-param name="replace" select="$replace" />
              <xsl:with-param name="by" select="$by" />
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$text" />
          </xsl:otherwise>
        </xsl:choose>
      </xsl:template>
    
      
    
     <xsl:template name="getXMLData">
        <xsl:param name="newxml"/>
       <xsl:variable name="justchecking" select="msxsl:node-set($newxml)"/>
        <xsl:for-each select="msxsl:node-set($newxml)">
           <xsl:for-each select="/ncic:Message/cjis:HeaderSection">
          <xsl:for-each select="cjis:TransactionHeaderText">
            <xsl:apply-templates/>
          </xsl:for-each>
          <xsl:for-each select="cjis:TransactionOrganization/jxdm:OrganizationORIID/jxdm:ID">
            <xsl:call-template name="nl_print"/>
          </xsl:for-each>
        </xsl:for-each>
     </xsl:for-each>
    </xsl:template>
    
      <xsl:template name="nl_print">
        <xsl:call-template name="cr"/>
        <xsl:value-of select="."/>
      </xsl:template>
    
      <xsl:template name="cr">
        <!-- INSERT WHATEVER YOU WANT THE LINE SEPARATOR TO BE INSIDE THE <xsl:text> TAGS -->
        <!--<xsl:text>
    </xsl:text>-->
        <!-- DECIMAL ASCII CODES FOR CR/LF -->
        <!-- <xsl:text>&lt;br&gt;</xsl:text>HTML <br> CODE -->
        <xsl:text disable-output-escaping="yes">&lt;br&gt;</xsl:text>
      </xsl:template>
      
    </xsl:stylesheet>
    Code:
    <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns5:CorrelatedMessageResponse xmlns:ns1="http://niem.gov/niem/appinfo/2.0" xmlns:ns2="http://niem.gov/niem/structures/2.0" xmlns:ns3="https://collect.prodcjis.ct.gov/ctsp/ext/1.0" xmlns:ns4="https://collect.prodcjis.ct.gov/ctsp/cjis/1.0" xmlns:ns5="https://collect.prodcjis.ct.gov/ctsp/queries/1.0" xmlns:ns6="https://collect.prodcjis.ct.gov/ctsp/messages/1.0" xmlns:ns7="https://collect.prodcjis.ct.gov/ctsp/NLETS/1.0"><ns3:ResponseFormat>XML</ns3:ResponseFormat><ns5:MessageResponse>[redacted entity-encoded XML]</ns5:MessageResponse></ns5:CorrelatedMessageResponse></soapenv:Body></soapenv:Envelope>
    Last edited by requinix; January 2nd, 2014 at 03:25 PM. Reason: xml redacted at poster's request

IMN logo majestic logo threadwatch logo seochat tools logo