Subject: [xsl] Running xsltproc does not produce any output From: "ohaya ohaya@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Sun, 21 Jul 2024 14:43:24 -0000 |
Hi, I am doing some work with a product that produces XML in the syslog output, and the product configuration allows for specifying an XSLT to transform the raw XML into text format, and they provide several base example XSLT for different targets. I am going to have to modify one of the base XSLTs so I wanted to try xsltproc (on CENTOS) to test/debug, but when I ran a sample XML output using one of the base XSLTs, xsltproc doesn't produce any output (and no errors either), so I was hoping someone might be able to tell me why. The base XSLT references an additional small XSLT via an "xsl:import". Here's the base XSLT: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> B B B <xsl:import href='rfc.xsl'/> B B B <xsl:output method='text' version='1.0' encoding='UTF-8'/> B B B <xsl:key name="CAProperty_Name" match="CAProperty" use="@Name"/> B B B <xsl:template match="/"> B B B B B B B <xsl:apply-imports/> B B B B B B B <xsl:for-each select="syslog/audit_record"><xsl:if test="not(key('CAProperty_Name','KeyDescription')) and not(key('CAProperty_Name','ApplicationObjectID')) and (Action = 'Retrieve password' or Action = 'Use Password' or Action = 'Retrieve SSH Key' or Action = 'CPM Change Password' or Action = 'CPM Reconcile Password')">|<xsl:value-of select="Issuer"/>|<xsl:value-of select="IsoTimestamp"/>|<xsl:value-of select="Action"/>|<xsl:call-template name="print-file-category"><xsl:with-param name="category-name" select="'UserName'" /></xsl:call-template><xsl:call-template name="print-file-category"><xsl:with-param name="category-name" select="'Address'" /></xsl:call-template><xsl:call-template name="print-file-category"><xsl:with-param name="category-name" select="'PolicyID'" /></xsl:call-template><xsl:call-template name="print-file-category"><xsl:with-param name="category-name" select="'DeviceType'" /></xsl:call-template><xsl:call-template name="print-file-category"><xsl:with-param name="category-name" select="'Database'" /></xsl:call-template><xsl:call-template name="print-file-category"><xsl:with-param name="category-name" select="'AWSAccountID'" /></xsl:call-template><xsl:call-template name="print-file-category"><xsl:with-param name="category-name" select="'AWSAccessKeyID'" /></xsl:call-template><xsl:call-template name="print-file-category"><xsl:with-param name="category-name" select="'ActiveDirectoryID'" /></xsl:call-template> B B B B B B B B B B B </xsl:if> B B B B B B B </xsl:for-each> B B B B B B B <xsl:for-each select="syslog/audit_record"><xsl:if test="Action = 'Logon' or Action = 'User Authentication'">|<xsl:value-of select="Issuer"/>|<xsl:value-of select="IsoTimestamp"/>|<xsl:value-of select="Action"/>|<xsl:value-of select="Station"/>|</xsl:if> B B B B B B B </xsl:for-each> B B B B B B B <xsl:for-each select="syslog/audit_record"><xsl:if test="Action = 'Store password' or Action = 'Store SSH Key'">|<xsl:value-of select="IsoTimestamp"/>|<xsl:value-of select="Action"/>|<xsl:value-of select="Safe"/>|<xsl:value-of select="File"/>|</xsl:if> B B B B B B B </xsl:for-each> B B B B B B B B B B B <!-- MessageID = '361' is PSM SSH Command AuditB B B B B B B B B B B B B B B B B B B B --> B B B B B B B B B B B <!-- MessageID = '359' is PSM SQL Command AuditB B B B B B B B B B B B B B B B B B B B --> B B B B B B B B B B B <!-- MessageID = '411' is PSM Window Title Command Audit --> B B B B B B B B B B B <!-- MessageID = '412' is PSM KeyStrokes Command AuditB B B B B --> B B B B B B B B B B B <!-- MessageID = '436' is PSM SCP Command AuditB B B B --> B B B B B B B B B B B <!-- MessageID = '300' is PSM Session Connect Audit --> B B B B B B B B B B B <!-- MessageID = '302' is PSM Session Disconnect AuditB B B B B --> B B B B B B B <xsl:for-each select="syslog/audit_record"><xsl:if test="MessageID = '361' or MessageID = '359' or MessageID = '411' or MessageID = '412' or MessageID = '436' or MessageID = '300' or MessageID = '302'">|<xsl:value-of select="Issuer"/>|<xsl:value-of select="IsoTimestamp"/>|<xsl:value-of select="MessageID"/>|<xsl:value-of select="Action"/>|<xsl:value-of select="Station"/>|<xsl:value-of select="File"/>|<xsl:call-template name="print-file-category"><xsl:with-param name="category-name" select="'PolicyID'" /></xsl:call-template><xsl:call-template name="print-file-category"><xsl:with-param name="category-name" select="'Address'" /></xsl:call-template><xsl:call-template name="print-file-category"><xsl:with-param name="category-name" select="'DeviceType'" /></xsl:call-template><xsl:call-template name="print-file-category"><xsl:with-param name="category-name" select="'Database'" /></xsl:call-template><xsl:value-of select="ExtraDetails"/>|</xsl:if> B B B B B B B </xsl:for-each> B B B B B B B B B B B <!-- MessageID = '471' is Grant Administrative Access Succeeded Syslog --> B B B B B B B <xsl:for-each select="syslog/audit_record"><xsl:if test="MessageID = '471'">|<xsl:value-of select="IsoTimestamp"/>|<xsl:value-of select="MessageID"/>|<xsl:value-of select="Issuer"/>|<xsl:value-of select="Action"/>|<xsl:value-of select="Station"/>|<xsl:value-of select="ExtraDetails"/>|</xsl:if> B B B B B B B </xsl:for-each> B B B </xsl:template> B B B <!-- replace all occurences of the character(s) `from' B B B B B B B B by the string `to' in the string `string'.--> B B B <xsl:template name="string-replace" > B B B B B B B <xsl:param name="string"/> B B B B B B B <xsl:param name="from"/> B B B B B B B <xsl:param name="to"/> B B B B B B B <xsl:choose> B B B B B B B B B B B <xsl:when test="contains($string,$from)"> B B B B B B B B B B B B B B B <xsl:value-of select="substring-before($string,$from)"/> B B B B B B B B B B B B B B B <xsl:value-of select="$to"/> B B B B B B B B B B B B B B B <xsl:call-template name="string-replace"> B B B B B B B B B B B B B B B B B B B <xsl:with-param name="string" select="substring-after($string,$from)"/> B B B B B B B B B B B B B B B B B B B <xsl:with-param name="from" select="$from"/> B B B B B B B B B B B B B B B B B B B <xsl:with-param name="to" select="$to"/> B B B B B B B B B B B B B B B </xsl:call-template> B B B B B B B B B B B </xsl:when> B B B B B B B B B B B <xsl:otherwise> B B B B B B B B B B B B B B B <xsl:value-of select="$string"/> B B B B B B B B B B B </xsl:otherwise> B B B B B B B </xsl:choose> B B B </xsl:template> B B B <xsl:template name="print-file-category"> B B B B B B B <xsl:param name="category-name"/> B B B B B B B <xsl:param name="print-pipe-if-empty" select="true()"/> B B B B B B B <xsl:variable name="out"> B B B B B B B B B B B <xsl:for-each select="CAProperties/CAProperty"> B B B B B B B B B B B B B B B <xsl:choose> B B B B B B B B B B B B B B B B B B B <xsl:when test="@Name=$category-name"> B B B B B B B B B B B B B B B B B B B B B B B <xsl:value-of select="@Value" /> B B B B B B B B B B B B B B B B B B B </xsl:when> B B B B B B B B B B B B B B B </xsl:choose> B B B B B B B B B B B </xsl:for-each> B B B B B B B </xsl:variable> B B B B B B B <xsl:value-of select="$out" /> B B B B B B B <xsl:choose> B B B B B B B B B B B <xsl:when test="$print-pipe-if-empty and $out=''">|</xsl:when> B B B B B B B B B B B <xsl:when test="$out!=''">|</xsl:when> B B B B B B B </xsl:choose> B B B </xsl:template> </xsl:stylesheet> AND here's the small XSLT that is supposed to be imported: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method='text' version='1.0' encoding='UTF-8'/> <xsl:template match="*"> B B B B B B B <xsl:choose> B B B B B B B B B B <xsl:when test="audit_record/Rfc='yes'"> B B B B B B B B B B B B B B B B B B B B B B B <xsl:text><</xsl:text><!-- the character '<' --> B B B B B B B B B B B B B B B B B B B B B B B <xsl:choose> B B B B B B B B B B B B B B B B B B B B B B B B B B <xsl:when test="audit_record/Severity='Critical'">10</xsl:when> B B B B B B B B B B B B B B B B B B B B B B B B B B <xsl:when test="audit_record/Severity='Error'">7</xsl:when> B B B B B B B B B B B B B B B B B B B B B B B B B B <xsl:when test="audit_record/Severity='Info'">5</xsl:when> B B B B B B B B B B B B B B B B B B B B B B B B B B <xsl:otherwise>0</xsl:otherwise> B B B B B B B B B B B B B B B B B B B B B B B </xsl:choose> B B B B B B B B B B B B B B B B B B B B B B B <xsl:text>></xsl:text> <!-- the character '>' --> B B B B B B B B B B B B B B B B B B B B B B B <xsl:text>1 </xsl:text> <!-- Syslog Version --> B B B B B B B B B B B B B B B B B B B B B B B <xsl:value-of select="audit_record/IsoTimestamp"/> B B B B B B B B B B B B B B B B B B B B B B B <xsl:text> </xsl:text> <!-- space --> B B B B B B B B B B B B B B B B B B B B B B B <xsl:value-of select="audit_record/Hostname"/> B B B B B B B B B B B B B B B B B B B B B B B <xsl:text> </xsl:text> <!-- space --> B B B B B B B B B B B B B B B </xsl:when> B B B B B B B </xsl:choose> </xsl:template> </xsl:stylesheet> AND here's a sample XML that I captured: B <audit_record> B B B <Rfc>yes</Rfc> B B B <Timestamp>Jul 21 01:10:30</Timestamp> B B B <IsoTimestamp>2024-07-21T01:10:30Z</IsoTimestamp> B B B <Hostname>VAU01</Hostname> B B B <Vendor>Test</Vendor> B B B <Product>Vau</Product> B B B <Version>14.0.0000</Version> B B B <MessageID>412</MessageID> B B B <Desc>logging</Desc> B B B <Severity>Info</Severity> B B B <Issuer>xxxxx</Issuer> B B B <Action>logging</Action> B B B <SourceUser/> B B B <TargetUser/> B B B <Safe>My Safe</Safe> B B B <File>Root\Operating System-my.solutions-xxxxx</File> B B B <Station>xx.yy.4.8</Station> B B B <Location/> B B B <Category/> B B B <RequestId/> B B B <Reason/> B B B <ExtraDetails>Command=xxxxx$[Tab]xxxxx$;ConnectionComponentId=Users;DstHost=m y.solutions;Protocol=NC;ID=Server_W01;SessionID=0c97ce2e-c0a2-467d-952e-e1b81 a9a5149;SrcHost=xx.zz.0.24;TXTOffset=1593B;User=xxxxx;VIDOffset=39T;</ExtraDe tails> B B B <Message>Keystroke logging</Message> B B B <GatewayStation/> B B B <CAProperties> B B B B B <CAProperty Name="PolicyID" Value="Windows"/> B B B B B <CAProperty Name="UserName" Value="xxxxx"/> B B B B B <CAProperty Name="Address" Value="my.solutions"/> B B B B B <CAProperty Name="DeviceType" Value="Operating System"/> B B B B B <CAProperty Name="CPMDisabled" Value="No Reason"/> B B B B B <CAProperty Name="LogonDomain" Value="my"/> B B B B B <CAProperty Name="CreationMethod" Value="VWA"/> B B B </CAProperties> B </audit_record> This is the xsltproc command line I have been trying/using which is not outputting anything: xsltproc --xincludestyle --path "/tmp/jl/mulberry" /tmp/jl/mulberry/pta.xsl /tmp/jl/mulberry/auditrecord.xml I also tried with "-v": [root@nodejs mulberry]# xsltproc -v --xincludestyle --path "/tmp/jl/mulberry" /tmp/jl/mulberry/pta.xsl /tmp/jl/mulberry/auditrecord.xml creating dictionary for stylesheet reusing dictionary from /tmp/jl/mulberry/pta.xsl for stylesheet xsltParseStylesheetProcess : found stylesheet xsltPrecomputeStylesheet: removing ignorable blank node Reusing dictionary for document creating dictionary for stylesheet reusing dictionary from /tmp/jl/mulberry/rfc.xsl for stylesheet xsltParseStylesheetProcess : found stylesheet xsltPrecomputeStylesheet: removing ignorable blank node xsltParseTemplateContent: removing text xsltCompilePattern : parsing '*' xsltCompilePattern : parsed *, default priority -0.500000 added pattern : '*' priority -0.500000 parsed 1 templates xsltParseStylesheetKey: name CAProperty_Name Add key CAProperty_Name, match CAProperty, use @Name B B resulting pattern //CAProperty xsltCompilePattern : parsing '/' xsltCompilePattern : parsed /, default priority 0.500000 added pattern : '/' priority 0.500000 parsed 3 templates Resolving attribute sets references Creating sub-dictionary from stylesheet for transformation Registered 0 modules reusing transformation dict for output Registering global variables Registering global variables from /tmp/jl/mulberry/pta.xsl Registering global variables from /tmp/jl/mulberry/rfc.xsl xsltProcessOneNode: applying template '/' for / xsltForEach: select syslog/audit_record xsltForEach: select syslog/audit_record xsltForEach: select syslog/audit_record xsltForEach: select syslog/audit_record xsltForEach: select syslog/audit_record freeing transformation dictionary freeing dictionary from stylesheet freeing dictionary from stylesheet Does anyone know why the xsltproc would not output anything?B I was hoping/expecting that it would output text, similar to what I am seeing in the syslog, when I am testing. Thanks,Jim
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] [ANN] Thinking and Talking ab, B Tommie Usdin btusd | Thread | Re: [xsl] Running xsltproc does not, Martin Honnen martin |
[xsl] [ANN] Thinking and Talking ab, B Tommie Usdin btusd | Date | Re: [xsl] Running xsltproc does not, Martin Honnen martin |
Month |