How to get the value from sqf:user-entry? - schematron

I want to get two integers from the user when the user tries to apply a quick fix using schematron rules and use the values as variables in the replace operation. But I get the error saying "variable has not been declared"
I have this schematron rule that finds the first empty choice element in a step and prompts the user to apply a quick fix. When the user applies the quick fix, a dialog box appears and prompts the user to provide two integers. The user input will be used to calculate a range of step elements.
The schematron rule
<sch:rule context="choice[1][not(normalize-space())]">
<sch:assert test="choice[1][not(normalize-space())]" sqf:fix='editchoice'>great
</sch:assert>
</sch:rule>
the fix
<sqf:fix id="editchoice">
<sqf:description>
<sqf:title>Enter the last step number</sqf:title>
</sqf:description>
<sqf:user-entry name="step1" type="xs:integer" >
<sqf:description>
<sqf:title>Enter the first step to be converted to choice</sqf:title>
</sqf:description>
</sqf:user-entry>
<sqf:user-entry name="laststep" type="xs:integer">
<sqf:description>
<sqf:title>Enter the last step to be converted</sqf:title>
</sqf:description>
</sqf:user-entry>
<sqf:replace match="./ancestor::steps/step[position()>$step1 and not(position()>=$laststep)]" target='choice' node-type='keep'></sqf:replace>
</sqf:fix>
The expected result
$step1 and $laststep should be replaced with the userinput values.
actual result
Variable step1 has not been declared (or its declaration is not in scope)

Currently there is no implementation which supports the usage of user entries in the match attribute (I'm working on that...).
Meanwhile you have to do this:
<sqf:replace match="./ancestor::steps/step">
<sch:let name="pos" value="count(preceding-sibling::step) + 1"/>
<xsl:choose>
<xsl:when test="$pos > number($step1) and not($pos >= number($laststep))">
<choice/>
</xsl:when>
<xsl:otherwise>
<sqf:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</sqf:replace>
Note: you need the number() because the Oxygen nativ implementation does not support the type of user-entry yet.

Related

EiffelStudio finalize with contracts enabled

How to produce the Finalized executable with contract checking enabled? It is possible to keep the check statements intact, but can we keep all the pre/postconditions and class invariants?
I need this for testing a computationally expensive application and frozen with contracts executable is a bit too slow in my case.
The IDE shows a dialog on request for finalization that asks whether the assertions should be kept in the generated executable. The dialog is discardable. If you select the checkbox "Do not ask me again", the assertions will NOT be generated and the IDE will NOT show this dialog anymore. You can reset this selection by going to the Parameters (e.g., from the main menu: Tools | Parameters), and restoring the default value for the finalization dialog under Interface | Dialogs.
In the command line, the compiler accepts an option -keep right after -finalize. It tells the compiler to keep assertions when finalizing the executable.
Both the IDE and the compiler pick the settings which assertions should be generated from the project settings. You can specify them for every group (system/library/cluster) and every class individually.
Edit. Here is a minimal example with 2 files:
example.e:
class EXAMPLE create make feature
make
local
n: INTEGER
do
if n = 0 then f
elseif n = 1 then g
end
rescue
n := n + 1
print ({EXCEPTIONS}.tag_name)
retry
end
f require pre: out = "x" do end
g do ensure post: out = "x" end
end
example.ecf:
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-21-0" name="example">
<target name="example">
<root class="EXAMPLE" feature="make"/>
<option>
<assertions precondition="true" postcondition="true"/>
</option>
<setting name="console_application" value="true"/>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<cluster name="test" location="."/>
</target>
</system>
Compilation with the options -finalize -keep -config example.ecf -c_compile produces an executable that prints prepost.

af:inputFile is not calling valueChangeListener method

Summarize the problem
I'm trying to upload an image to a blob in the database and have been following various blogs online to do so.
Provide background including what you've already tried
I've tried enclosing the input file on a form but I get the warning:-
"Only one af:form is supported per page. This warning later escalates to a server exception error and I can't enter said page.
Show some code
<af:panelFormLayout id="pfl1">
<f:facet name="footer"/>
<af:form id="f1" usesUpload="true">
<af:inputFile label="Label 1" id="if1" value="#NewUploadImageBean.file}"
valueChangeListener="#{NewUploadImageBean.upLoadValueChangeListener}"/>
</af:form>
</af:panelFormLayout>
I only have this one form in the entire page.
Describe expected and actual results including any error messages
Would like to the valueChangeListner to call my method. Currently I get the
ADF_FACES-60097 error which then translates to : java.lang.IllegalStateException: ADF_FACES-30124:Multiple forms detected on viewId: /test_pages/employement.jsf. Rich client currently has some limitations in dealing with multiple forms.
How to fix ADF_FACES-30124:Multiple forms detected on viewId ?
To do so remove all the af:forms inside your jsf view expecially the one containing your inputFile and add only one af:form useupload="true" at the highest view tag level :
<af:document >
<af:form usesUpload="true" id="f1">
... ALL YOUR VIEW TAGS ...
</af:form>
</af:document>

Get the values from the <xd:doc/>

I want to access the version information which I store in the
<xsl:stylesheet>
<xd:doc scope="stylesheet">
<xd:ul>
<xd:li>
<xd:i>Updates</xd:i>: <xd:ul>
<xd:li>20.11.2018, version: <xd:i>1.1.0</xd:i></xd:li>
<xd:li>08.03.2019, version: <xd:i>2.0.0</xd:i></xd:li>
<xd:li>11.03.2019, version: <xd:i>2.0.1</xd:i></xd:li>
</xd:ul>
</xd:li>
</xd:ul>
</xd:doc>
</xsl:stylesheet>
Normally the XPath of the #select is evaluated to the xml-file which is currently transforming. But how refer XPath to the (main) XSL-stylesheet?
Another option would be to use fn:doc(). But I want to place the version-writing-functionality in an external module, so there will be dynamic file names and I don't know how to get the xsl-file name
I use oXygen XML editor 20.1 where I define the transformation scenarios.
#MartinHonnen Thank you. I updated the code in the question. As you may see I store the version in the docs of the stylesheet.
The document('') / doc('') was what I needed. So I implemented the following:
I put the document-node of the main stylesheet in the variable which is placed in this stylesheet:
<xsl:variable name="currentStylesheet" select="doc('')"/>
then refer to it in the external module
<xsl:variable as="xs:string" name="versionXSLT" select="$currentStylesheet//xd:li[xd:i = 'Updates']/xd:ul/xd:li[last()]/xd:i/string()"/>
I also use it to get the name of the stylesheet:
<xsl:variable as="xs:string" name="currentStylesheetName" select="tokenize(document-uri($currentStylesheet), '/')[last()]"/>
Are there maybe better solutions?

Prevent macOS generic keyboard driver from capturing usb-device

I'm trying to write a macOS user-level driver in C for a usb-device (a pentablet with buttons).
Currently this tablet gets recognized as generic mouse and generic keyboard from the system. Since the shortcuts applied to the buttons of the pentablet are not customizeable, I'd like to write my own driver for that.
What's working:
I am able to read the raw-data with hidapi (http://www.signal11.us/oss/hidapi/) from the device, which looks something like this:
A B C D E F G H
10 192 228 50 157 43 0 0
I figured out, that when I use the pen the values of the columns B-H change according to the pens position, pressure and click.
My problem:
However, I cannot figure out how to access the buttons of the device. Each time I press one of them, their hardcoded key-combination gets triggered. Since the values of column A never change, I assume that the device is still captured as a generic keyboard by the system, and so this column never shows me the currently pressed button and triggers it's key-combination.
Each time I press one of these buttons they all trigger a holding ALT/Option + Shift, additionally some of them trigger a character, and one of them triggers the volume up.
So, my approach was to use a codeless kext for preventing the system from capturing the device. But this doesn't work either - the device still gets captured by the system as a generic keyboard.
I disabled csrutil and with kextload, having my kext located in /Library/Extensions, I get a successfull message, that the kext is loaded:
Warnings:
Personality CFBundleIdentifier differs from containing kext's (not necessarily a mistake, but rarely done):
Tablet
Code Signing Failure: code signature is invalid
Warnings:
Personality CFBundleIdentifier differs from containing kext's (not necessarily a mistake, but rarely done):
Tablet
/Library/Extensions/foobartablet.kext appears to be loadable (not including linkage for on-disk libraries).
kext-dev-mode allowing invalid signature -67050 0xFFFFFFFFFFFEFA16 for kext "/Library/Extensions/foobartablet.kext"
kext signature failure override allowing invalid signature -67050 0xFFFFFFFFFFFEFA16 for kext "/Library/Extensions/foobartablet.kext"
Loading /Library/Extensions/foobartablet.kext.
Here's my info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>13C64</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleGetInfoString</key>
<string>1.0 Copyright © Adis Durakovic</string>
<key>CFBundleIdentifier</key>
<string>com.adisdurakovic.huitablet</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleShortVersionString</key>
<string>Huion Tablet 1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>5A2053</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>13A595</string>
<key>DTSDKName</key>
<string>macosx10.9</string>
<key>DTXcode</key>
<string>0501</string>
<key>DTXcodeBuild</key>
<string>5A2053</string>
<key>IOKitPersonalities</key>
<dict>
<key>Tablet</key>
<dict>
<key>CFBundleIdentifier</key>
<string>com.apple.kpi.iokit</string>
<key>IOClass</key>
<string>IOService</string>
<key>IOProviderClass</key>
<string>IOUSBDevice</string>
<key>idVendor</key>
<string>9580</string>
<key>idProduct</key>
<string>110</string>
<key>bcdDevice</key>
<string>12288</string>
<key>IOProbeScore</key>
<integer>200000</integer>
</dict>
<key>TabletNew</key>
<dict>
<key>CFBundleIdentifier</key>
<string>com.apple.kpi.iokit</string>
<key>IOClass</key>
<string>IOService</string>
<key>IOProviderClass</key>
<string>IOUSBHostDevice</string>
<key>idVendor</key>
<string>9580</string>
<key>idProduct</key>
<string>110</string>
<key>bcdDevice</key>
<string>12288</string>
<key>IOProbeScore</key>
<integer>300000</integer>
</dict>
</dict>
<key>OSBundleLibraries</key>
<dict/>
</dict>
</plist>
And here's also my ioreg -i -w 0 -l -n "PenTablet" output which I used for device matching:
https://adisdurakovic.com/pentablet.txt
What am I doing wrong here?
Since you mention SIP, I assume you're testing this on 10.11 or newer. Your IOProviderClass is set to IOUSBDevice - this will only work for 10.10 and older. 10.11 introduced a completely new USB stack, the new class name is IOUSBHostDevice. I know that's not what IORegistryExplorer/ioreg say: there's a translation going on somewhere to keep old userspace apps ticking over. In the kernel, drivers matching IOUSBHostDevice will take precedence over those matching IOUSBDevice. If you want to support both, you can just add an extra personality to your codeless kext. For kexts with code, you'll need to create two versions of your kext if the legacy support doesn't work in your case.
Another thing that could affect it is probe score, although in theory your idVendor + idProduct + bcdDevice rule should already have a very high score.

ADF problems with af:validateRegExp (binding Long field)

I have a portlet application in a WebCenter env. This application is made using JSF (with the ADF implementation), so I have a field like that:
<af:inputText visible="#{CadastrarFormularioContato.showCodigoEc}"
label="#{msg.CODIGODOEC}" id="it2" required="true"
requiredMessageDetail="#{msg.INFORMECODIGOEC}"
showRequired="true"
value="#{CadastrarFormularioContato.item.cdEstabelecimento}">
<af:validateRegExp messageDetailNoMatch="#{msg.CODIGOECSOMENTENUMEROS}" pattern="^[0-9]{1,}$"/>
<af:convertNumber type="number"/>
</af:inputText>
But, when I invoke the form submit i receive the follow error:
javax.portlet.faces.BridgeException: java.lang.IllegalArgumentException: 'value' is not of type java.lang.String.
My Object.longField is:
private Long longField
(with its getters/setters)
I try to use convert, convertNumber etc but with no sucess.
The problem is about the "validateRegExp" tag (if i remove it, works) So, why?
Any suggestion?
The validateRegExp only accepts Strings. If you can change the java class, then adding a String field to shadow the Long is an easy fix. If not, you can write your own regex validator.

Resources