GSA use connector for databases do not have metadata? - google-search-appliance

We are working on a GSA project. We are using GSA version 7.2 and Connector database adapter 3.2.4.
That SQL as
SELECT EMPLOYEE_ID,
FIRST_NAME,
LAST_NAME,
EMAIL,
PHONE_NUMBER,
HIRE_DATE,
JOB_ID,
SALARY,
COMMISSION_PCT,
MANAGER_ID,
DEPARTMENT_ID
FROM HR.EMPLOYEES ;
How to write "Stylesheet for Serving Results" for show all metadata from SQL.

You must customize stylesheet as follow:
`<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<head>
<xsl:for-each select="pland_connector"> <!-- name of connector -->
<!-- now for every single field from the database you want to be able to filter upon or show in your result, add a meta-field -->
<title><xsl:value-of select="LAST_NAME"/></title> <!-- don't forget the title -> that is the default title in the GSA result -->
<meta name="EMPLOYEE_ID"><xsl:attribute name="content"><xsl:value-of select="EMPLOYEE_ID"/></xsl:attribute></meta>
<!-- mind the capital sensitivity of XML, dependend on the notation in you db view or table the value-of should be in capitals or not -->
<meta name="LAST_NAME"><xsl:attribute name="content"><xsl:value-of select="LAST_NAME"/></xsl:attribute></meta>
<meta name="FIRST_NAME"><xsl:attribute name="content"><xsl:value-of select="FIRST_NAME"/></xsl:attribute></meta>
<meta name="EMAIL"><xsl:attribute name="content"><xsl:value-of select="EMAIL"/></xsl:attribute></meta>
<meta name="PHONE_NUMBER"><xsl:attribute name="content"><xsl:value-of select="PHONE_NUMBER"/></xsl:attribute></meta>
<!-- Etc..... -->
</xsl:for-each>
<!-- You can add static metadata to -->
<meta name="test" content="Person"/>
</head>
<body>
<!-- Just see what data you want in the content-field -->
<xsl:for-each select="pland_connector"> <!-- Name of database -->
<h1><xsl:value-of select="NAME"/></h1></br>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>`
I think you will completed.

Related

XSLTProcessor returns 0x80600004 (NS_ERROR_XSLT_EXECUTION_FAILURE)

I've got the following HTML doc trying to transform some xml:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta charset="utf-8"/>
<script>
var rawXml = `<?xml version="1.0" encoding="UTF-8"?>
<songs>
<song name="She loves you" artist="Beatles"/>
<song name="Yesterday" artist="Beatles "/>
<song name="Satisfaction" artist="Rolling Stones"/>
<song name="My Generation" artist="Who"/>
<song name="Under My Thumb" artist="Rolling Stones"/>
</songs>`;
var rawXsl = `<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<table>
<tr>
<th>Artist</th>
<th>Song list</th>
</tr>
<!-- <xsl:for-each select="songs/song"> -->
<!-- <tr> -->
<!-- <td><xsl:value-of select="#artist"/></td> -->
<!-- <td><xsl:value-of select="#name"/></td> -->
<!-- </tr> -->
<!-- </xsl:for-each> -->
<xsl:for-each-group select="songs/song" group-by="#artist">
<tr>
<td><xsl:value-of select="current-grouping-key()"/></td>
<td><xsl:value-of select="current-group()/#name" separator=","/></td>
</tr>
</xsl:for-each-group>
</table>
</xsl:template>
</xsl:stylesheet>`;
function parseXml(text)
{
var parser = new DOMParser();
var xml = parser.parseFromString(text, "application/xml");
return xml;
}
function displayContent()
{
var xml = parseXml(rawXml);
var xsl = parseXml(rawXsl);
var xsltProcessor = new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
var resultDocument = xsltProcessor.transformToFragment(xml, document);
var target = document.getElementById("contentTarget");
target.appendChild(resultDocument);
}
</script>
</head>
<body onload="displayContent()">
<div id="contentTarget"></div>
</body>
</html>
So in firefox I get said error 0x80600004 (NS_ERROR_XSLT_EXECUTION_FAILURE) and TBH, I have no idea why. I also tried it in Edge Chromium, there I just see the table header and apparently execution stops when trying to group, but I'm not able to make edge report any error.
If you comment in the xsl:for-each and comment out xsl:for-each-group, it works perfectly fine.
What am I doing wrong, when trying to group?
The answer is simple:
ALL Browsers (unfortunately) only support XSLT-1.0. But the for-each-group instruction is part of XSLT-2.0. So if you use it, the stylesheet will not work (See Grouping With XSLT 2.0).
Solution:
Stick to XSLT-1.0 instructions and complain vigorously to the browser creators.

How to tell template match to not run on specific text that's part of a span?

I need this script to run on all files that do not contain the text behavioral_science that's included in the span called atom:tag.
Here's the template match in my script:
<xsl:template match="xhtml:section[#data-title = 'Step-by-Step'][not(contains(ancestor::xhtml:li[#property = 'ktp:question'],'behavioral_sciences'))]">
This is the span line in my HTML:
<span property="atom:tag" class="ktp-meta">behavioral_sciences</span>
The script right now is looking for any text containing behavioral_science but I need to only look for behavioral_science that's part of the atom:tag span. What am I missing in my XSLT code?
This is more of the HTML code Im running the XSLT script on:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" class="ktp-question-set" data-uuid="90dcafa425ef42dca522211db2db1f1f">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta charset="utf-8" />
<link type="text/css" rel="stylesheet" title="default" href="../../assets/css/main.css" />
<title>mbeh01001</title>
</head>
<body>
<ol class="ktp-question-set" data-uuid="0b866e6990f940e8b22d8083bff94248">
<li id="mbeh01001" property="ktp:question" typeof="ktp:Question" data-uuid="3e34491dfadd46b58de842471aafd503" class="ktp-question">
<section class="ktp-question-meta" data-uuid="01e5e879ddda4f4889f1378655a4a3bd">
<section property="ktp:metadata" class="ktp-meta" data-uuid="e7e38b9d85e045b4a7e6492b2f286cdb">
<span property="atom:content-item-name" class="ktp-meta" data-value="mbeh01001"></span>
</section>
<section property="ktp:tags" class="ktp-meta" data-uuid="fda3a2342a1546d59cfe4bb37f6198cb">
<span property="ktp:interactionType" class="ktp-meta">single-select</span>
<span property="ktp:authorName" class="ktp-meta">Ari Morgenstern</span>
<span property="ktp:subject" class="ktp-meta">Behavioral Sciences</span>
<span property="jasper:catRef-MCAT2015-QTopic" class="ktp-meta">ps.behsci.bb.infbeh</span><span property="atom:tag" class="ktp-meta">behavioral_sciences</span>
</section>
</section>
</body>
</html>
This is the full template match code in my XSLT script:
<xsl:template match="xhtml:section[#data-title = 'Step-by-Step'][not(.//xhtml:span[#property = 'atom:tag' and contains(., 'behavioral_sciences')])]">
<xsl:variable name="separate_class" select="tokenize(#class,'\s')"/>
<xsl:choose>
<xsl:when test="$separate_class='jasper-exclude'">
<xsl:copy>
<xsl:attribute name="class"><xsl:value-of select="concat('atom-exclude ',$separate_class[not(contains(.,'jasper-exclude'))])"></xsl:value-of></xsl:attribute>
<xsl:apply-templates select="#* except #class | node()"/>
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="#* | node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
If you want to block any such span from producing output then usually doing <xsl:template match="span[#property = 'atom:tag' and . = 'behavioral_sciences']"/> or with contains as <xsl:template match="span[#property = 'atom:tag' and contains(., 'behavioral_sciences')]"/> achieves that.
It is not clear how that span relates to that template also given and its element section but that pattern rewritten to look for any span descendants would be
<xsl:template match="xhtml:section[#data-title = 'Step-by-Step'][not(.//xhtml:span[#property = 'atom:tag' and contains(., 'behavioral_sciences')])]">

PowerPoint add-in does not work in Slide Show (fullscreen) in PowerPoint Online

We're currently developing a PowerPoint add-in and we have trouble making it work in Slide Show (fullscreen) in PowerPoint Online, which recently caused it to be rejected from the Office Store.
Here is a minimal example which reproduces the bug, based on the How-To guide:
index.html
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. -->
<!-- See LICENSE in the project root for license information -->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My Office Add-in</title>
<!-- Office JavaScript API -->
<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js"></script>
<!-- LOCAL -->
<link rel="stylesheet" href="node_modules/office-ui-fabric-js/dist/css/fabric.min.css" />
</head>
<body class="ms-font-m ms-welcome">
<h1>Hello World</h1>
<script type="text/javascript" src="node_modules/core-js/client/core.js"></script>
<script type="text/javascript" src="node_modules/jquery/dist/jquery.js"></script>
<script type="text/javascript" src="node_modules/office-ui-fabric-js/dist/js/fabric.js"></script>
<script type="text/javascript" src="app.js"></script>
</body>
</html>
app.js
"use strict";
(function() {
// The initialize function must be run each time a new page is loaded
Office.initialize = function(reason) {
$(document).ready(function() {
$("#run").click(run);
});
};
function run() {
return PowerPoint.run(function(context) {
/**
* Insert your PowerPoint code here
*/
return context.sync();
});
}
})();
counter-manifest.xml
<?xml version="1.0" encoding="UTF-8"?>
<OfficeApp
xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="ContentApp">
<Id>71a1a0ed-6cd0-4a6e-ad2d-015b8a8b43cb</Id>
<Version>1.0.0.0</Version>
<ProviderName>Test</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="DisplayName" />
<Description DefaultValue="Description"/>
<IconUrl DefaultValue="https://localhost:3004/assets/icon-32.png" />
<HighResolutionIconUrl DefaultValue="https://localhost:3004/assets/hi-res-icon.png"/>
<AppDomains></AppDomains>
<Hosts>
<Host Name="Presentation" />
</Hosts>
<DefaultSettings>
<SourceLocation DefaultValue="https://localhost:3004/index.html" />
</DefaultSettings>
<Permissions>ReadWriteDocument</Permissions>
<VersionOverrides
xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
<Hosts>
<Host xsi:type="Presentation"></Host>
</Hosts>
<Resources></Resources>
</VersionOverrides>
</OfficeApp>
We're serving our add-in using Browsersync as explained in the How-To guide. When I add it to a blank presentation in PowerPoint Online, it seems to work as expected (except for a different bug when refreshing described here) until I try to go into Slide Show (fullscreen) mode. I see a loading animation in fullscreen for a few seconds then I'm back to the previous editor mode.
Here are the errors displayed in the Chrome Developer Tools Console when trying to enter SlideShow mode:
Refused to get unsafe header "X-WacCluster"
Refused to get unsafe header "X-SupportSVGInWebGL"
Failed to load https://euc-powerpoint.officeapps.live.com/pods/RemoteUls.ashx: The 'Access-Control-Allow-Origin' header contains multiple values 'https://contentstorage.osi.office.net, https://contentstorage.osi.office.net', but only one is allowed. Origin 'https://contentstorage.osi.office.net' is therefore not allowed access.
Uncaught TypeError: Cannot read property '$37' of null
at PPTe.$22.$17a (VM3959 11b10a4995dd8c5f.js:10)
How can we ensure that our add-in works correctly in Slide Show mode?

Cordova AJAX request without whitelist

I've been trying to make a ajax request
$.ajax({
type: "GET",
dataType: "json",
url: "http://testing.com/ws/check?" + outputData,
success: onSuccess,
error: onError
});
But it fails with a 404 error, after a long search I found that I was missing the whitelist plugin but from what I've search Whitelist is only for Android 4+ and IOS 4+, will windows work? and blackberry?
is there a way to do this without adding whitelist?
If white list is really required why does it give me this error?
Refused to apply inline style because it violates the following Content Security Policy directive: "default-src 'self' https:". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'style-src' was not explicitly set, so 'default-src' is used as a fallback.
My html:
<!-- CSP support mode (required for Windows Universal apps): https://docs.angularjs.org/api/ng/directive/ngCsp -->
<html lang="en" ng-app="app" ng-csp>
<head>
<!-- Setting environment up -->
<meta charset="utf-8" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name='viewport' content='width=device-width, maximum-scale=1.0, user-scalable=no, target-densityDpi=device-dpi'>
<!-- -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com; style-src 'self' 'unsafe-inline'; media-src *">
<!-- Enable all requests, inline styles, and eval() -->
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
<!-- Allow XHRs via https only -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self' https:">
<!-- Allow iframe to https://cordova.apache.org/ -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; frame-src 'self' https://cordova.apache.org">
<!-- JS dependencies (order matters!) -->
<script src="scripts/platformOverrides.js"></script>
<script src="lib/angular/angular.js"></script>
<script src="lib/jquery/jquery-1.11.3.min.js"></script>
<script src="lib/onsen/js/onsenui.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<!-- -->
<!-- CSS dependencies -->
<link rel="stylesheet" href="lib/onsen/css/onsenui.css" />
<link rel="stylesheet" href="lib/onsen/css/onsen-css-components-blue-basic-theme.css" />
<!-- -->
<!-- CSP support mode (required for Windows Universal apps) -->
<link rel="stylesheet" href="lib/angular/angular-csp.css" />
<!-- -->
<!-- --------------- App init --------------- -->
<script src="js/app.js"></script>
<script src="js/Pages/SplashScreen.js"></script>
<script src="js/utils.js"></script>
<link rel="stylesheet" href="css/app.css" />
<!-- -->
<!-- Application Title -->
<title>Testing</title>
<!-- -->
</head>
<body ng-controller="AppController">
<!-- Cordova reference -->
<script src="scripts/index.js"></script>
<!-- -->
<!-- Navigator! Everything runs inside it! -->
<ons-navigator var="navi">
</ons-navigator>
<!-- -->
<!-- Templates -->
<!-- Splashscreen -->
<ons-template id="splashScreen.html" style="background:none">
<ons-page id="splashScreen" ng-controller="SplashScreenController">
<div id="splashScreen2" class="background_image">
<img id="background-image" width="100%" height="100%">
</div>
</ons-page>
</ons-template>
<!-- -->
<div id="result"/>
</body>
</html>
Thank you,
Joao
First You should install Cordova whitelist plugin(I think you have already it).
And after that add the following to config.xml file which is found in platforms/<platform name>/res/xml directory.
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />

Xpath: Select node but not specific child elements

I have a structure similar to the following:
<page id='1'>
<title>Page 1</title>
<page id='2'>
<title>Sub Page 1</title>
</page>
<page id='3'>
<title>Sub Page 2</title>
</page>
</page>
<page id='4'>
<title>Page 2</title>
</page>
I need to select a page by Id but if that page has descendant pages I don't want to return those elements, but I do want the other elements of that page. If I select Page 1 I want to return title but not the child pages...
//page[#id=1]
The above gets me page 1, but how do I exclude the sub pages? Also, There could be any arbitrary number of elements in a page.
//page[#id=1]/*[not(self::page)]
I have found that this gets me the data I want. However, that data comes back as an array of objects with one object per element and apparently excludes the element names???. I am using PHP SimpleXML for what it is worth.
Use:
//page[#id=$yourId]/node()[not(self::page)]
This selects all nodes that are not page and that are children of any page in the document, the string value of whose id attribute is equal to the string contained in $yourId (most probably you would substitute $yourId above with a specific, desired string, such as '1').
Here is a simple XSLT-based verification:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:param name="pId" select="3"/>
<xsl:template match="/">
<xsl:copy-of select="//page[#id=$pId]/node()[not(self::page)]"/>
</xsl:template>
</xsl:stylesheet>
when this transformation is applied on the provided XML document (wrapped in a single top node to make it well-formed):
<pages>
<page id='1'>
<title>Page 1</title>
<page id='2'>
<title>Sub Page 1</title>
</page>
<page id='3'>
<title>Sub Page 2</title>
</page>
</page>
<page id='4'>
<title>Page 2</title>
</page>
</pages>
the wanted, correct result is produced:
<title>Sub Page 2</title>
Do note: One assumption made is that an id value uniquely identifies a page. If this is not so, the proposed XPath expression will select all page elements whose id attribute has a string valu of $yourId.
If this is the case and only one page element must be selected, the OP must specify which one of the many page elements with this id should be selected.
For example, it may be the first:
(//page[#id=$yourId]/node()[not(self::page)])[1]
or the last:
(//page[#id=$yourId]/node()[not(self::page)])[last()]
or ...
If you're only interested in the title element, this would work:
//page[#id=1]/title
If however you need other sub elements of page, I'm not sure XPath is the right tool for you.
Sounds more like something that an XSLT would be suited for, since what you are really doing is transforming your data.
If the page always has a title:
//page[#id='1']/*[not(boolean(./title))]

Resources