strange counting in Asciidoctor? - asciidoctor

I want to count my figures automatically
I use Asciidcotor 1.5.6
:desc-image-fr: FR Text
[id="image-fr",reftext="{figure-caption} {counter:figures}"]
.{desc-image-fr}
image::fr.png[align="center"]
:desc-image-ab: AB Text
.{desc-image-ab}
[plantuml,id="image-ab",format="png",title="{desc-image-ab}" reftext="{figure-caption} {counter:figures}",align="center"]
----
() "FR" as GS
() "AB" as AB
----
look in <<image-ab>> and <<image-fr>>
This is the result:
...here is the image...
Figure 3. FR Text
...here is rendered png of plantuml...
Figure 5. AB Text
look in Figure 4 and Figure 3
I am surprised about the "Figure 5"... Why 5 and not 4?
EDIT: added info from pom.xml
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>1.5.6</version>
<dependencies>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-complete</artifactId>
<version>9.1.12.0</version>
</dependency>
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj-pdf</artifactId>
<version>1.5.0-alpha.16</version>
</dependency>
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj-diagram</artifactId>
<version>1.5.18</version>
</dependency>
</dependencies>
Why the extension is not activated?

Related

Antlr no viable alternative at input when the keyword is POINT

import org.antlr.v4.runtime.tree.ParseTree;
import org.apache.shardingsphere.sql.parser.core.parser.SQLParserExecutor;
import org.junit.Test;
import javax.xml.bind.SchemaOutputResolver;
public class T1 {
#Test
public void t1() {
ParseTree parseTree = new SQLParserExecutor("MySQL", "insert into T_NAME (POINT) values (?)").execute().getRootNode();
}
}
This code will report the following error:
line 1:20 no viable alternative at input '(POINT'
When I use other column names, it’s all right, but POINT doesn’t work. Why?
Java project, pom.xml:
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-namespace</artifactId>
<version>4.1.1</version>
</dependency>
I suspect that all (MySQL), or more, keywords would trigger this error (POLYGON probably also produces this error). The grammar probably is trying to match an identifier, but since the input POINTS is already matched as a keyword, it fails to match it properly.
Something like this:
insert_stat
: INSERT INTO? table_name '(' column_names ')' ...
;
column_names
: IDENTIFIER ( ',' IDENTIFIER )*
;
Looking at the Github issue, one of the maintainers indicated that the 5.0.0-alpha properly handles this, meaning they probably did something like this to fix it:
insert_stat
: INSERT INTO? table_name '(' column_names ')' ...
;
column_names
: identifier ( ',' identifier )*
;
identifier
: IDENTIFIER
| POINT
| POLYGON
| ...
;
I.e.: they extended the set of valid identifiers inside the parser.
Thanks for #Bart's comment Here. This bug has been fixed from 5.0.0-alpha.
BTW, ShardingSphere supports many mainstream RDBMS, like MySQL, PostgreSQL, SQLServer and Oracle. Therefore you will see a great many g4 files in this repo. Ideally, these definitions in Antlr g4 file are expected to be aligned with the corresponding official SQL docs. So if there is any mismatch, please report that at ISSUES. Thanks a lot.

Mapserver trouble wrapping cgi-bin/mapserv and map=mapfile.map

I am using Mapserver 7.0.7 (MS4W 3.2.8) and i'm having trouble wrapping cgi-bin/mapserv and map=mapfile.map
work fine in
http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/apps/Leaflet/mapserver/Leaflet.map&service=WMS&request=GetMap&layers=LAT&styles=&format=image%2Fpng&transparent=true&version=1.3.0&tiled=true&width=512&height=512&crs=EPSG%3A3857&bbox=-6574807.424977722,-3443946.7464169012,-6261721.357121639,-3130860.67856082
result
using RewriteRule in .htaccess into the folder on my leafletjs web
RewriteRule ^ms(.*)$ http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/apps/Leaflet/mapserver/Leaflet.map$1
http://10.1.3.21/Leaflet/ms&service=WMS&request=GetMap&layers=LAT&styles=&format=image%2Fpng&transparent=true&version=1.3.0&tiled=true&width=512&height=512&crs=EPSG%3A3857&bbox=-6574807.424977722,-3443946.7464169012,-6261721.357121639,-3130860.67856082
result:
Not Found
The requested URL /Leaflet/ms&service=WMS&request=GetMap&layers=LAT&styles=&format=image/png&transparent=true&version=1.3.0&tiled=true&width=512&height=512&crs=EPSG:3857&bbox=-6574807.424977722,-3443946.7464169012,-6261721.357121639,-3130860.67856082 was not found on this server.
but is a working GetCapabilities request
http://localhost/Leaflet/ms&service=WMS&version=1.0.0&request=GetCapabilities
and it is replaced as =>
http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/apps/Leaflet/mapserver/Leaflet.map&service=WMS&version=1.0.0&request=GetCapabilities
result:
<!-- end of DOCTYPE declaration -->
<WMT_MS_Capabilities version="1.0.0">
<!--
MapServer version 7.0.7 (MS4W 3.2.8) OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO SUPPORTS=SVG_SYMBOLS SUPPORTS=SVGCAIRO SUPPORTS=ICONV SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=FASTCGI SUPPORTS=THREADS SUPPORTS=GEOS SUPPORTS=POINT_Z_M INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
-->
<Service>
<Name>GetMap</Name>
<Title>Leaflet - WMS</Title>
<OnlineResource>http://localhost/Leaflet/ms?</OnlineResource>
</Service>
...
Your rewrite rule is removing the important ? querystring character, creating an invalid request such as /Leaflet/ms&service=WMS&... but it should result as /Leaflet/ms?service=WMS... Try a rule such as:
RewriteRule ^ms?(.*)$ http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/apps/Leaflet/mapserver/Leaflet.map$1

Mapping excel to XML - Problem importing XML-fields

I seem to have a problem with mapping XML parts to an existing exceltable.
I have a sample XML file provided from the Swedish tax authority as XML-schema:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Skatteverket xmlns="http://xmls.skatteverket.se/se/skatteverket/ai/instans/infoForBeskattning/4.0"
xmlns:gm="http://xmls.skatteverket.se/se/skatteverket/ai/gemensamt/infoForBeskattning/4.0"
xmlns:ku="http://xmls.skatteverket.se/se/skatteverket/ai/komponent/infoForBeskattning/4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" omrade="Kontrolluppgifter"
xsi:schemaLocation="http://xmls.skatteverket.se/se/skatteverket/ai/instans/infoForBeskattning/4.0
http://xmls.skatteverket.se/se/skatteverket/ai/kontrolluppgift/instans/Kontrolluppgifter_4.0.xsd ">
<ku:Avsandare>
<ku:Programnamn>KUfilsprogrammet</ku:Programnamn>
<ku:Organisationsnummer>162234567895</ku:Organisationsnummer>
<ku:TekniskKontaktperson>
<ku:Namn>Bo Ek</ku:Namn>
<ku:Telefon>+46881234567</ku:Telefon>
<ku:Epostadress>bo.ek#elbolagetab.se</ku:Epostadress>
<ku:Utdelningsadress1>Strömgatan 11</ku:Utdelningsadress1>
<ku:Postnummer>62145</ku:Postnummer>
<ku:Postort>Strömby</ku:Postort>
</ku:TekniskKontaktperson>
<ku:Skapad>2015-06-07T21:32:52</ku:Skapad>
</ku:Avsandare>
<ku:Blankettgemensamt>
<ku:Uppgiftslamnare>
<ku:UppgiftslamnarePersOrgnr>165599990602</ku:UppgiftslamnarePersOrgnr>
<ku:Kontaktperson>
<ku:Namn>John Ström</ku:Namn>
<ku:Telefon>+46812345678</ku:Telefon>
<ku:Epostadress>siv.strom#elbolagetab.se</ku:Epostadress>
<ku:Sakomrade>Förnybar el</ku:Sakomrade>
</ku:Kontaktperson>
</ku:Uppgiftslamnare>
</ku:Blankettgemensamt>
<!-- Kontrolluppgift 1 -->
<ku:Blankett nummer="2350">
<ku:Arendeinformation>
<ku:Arendeagare>165599990602</ku:Arendeagare>
<ku:Period>2018</ku:Period>
</ku:Arendeinformation>
<ku:Blankettinnehall>
<ku:KU66>
<ku:UppgiftslamnareKU66>
<ku:UppgiftslamnarId faltkod="201">165599990602</ku:UppgiftslamnarId>
<ku:NamnUppgiftslamnare faltkod="202">Sonjas elhandel</ku:NamnUppgiftslamnare>
</ku:UppgiftslamnareKU66>
<ku:Inkomstar faltkod="203">2018</ku:Inkomstar>
<ku:KWhMatatsIn faltkod="270">3622</ku:KWhMatatsIn>
<ku:KWhTagitsUt faltkod="271">4822</ku:KWhTagitsUt>
<ku:AnlaggningsID faltkod="272">735999123456789012</ku:AnlaggningsID>
<ku:AndelIAnslPunkt faltkod="273">12.5</ku:AndelIAnslPunkt>
<ku:Specifikationsnummer faltkod="570">128</ku:Specifikationsnummer>
<ku:InkomsttagareKU66>
<ku:Inkomsttagare faltkod="215">193804139149</ku:Inkomsttagare>
</ku:InkomsttagareKU66>
</ku:KU66>
</ku:Blankettinnehall>
</ku:Blankett>
</Skatteverket>
When using Excel, Developer tab -> XML -> Source and adding the file I don't seem to get the XML parts inside the tag
<ku:Blankettinnahall>
Any reason why Excel would skip these XML parts?
Here is some sample exceltable data that I would like to map to those XML-fields:
AnlaggningsID Inkomsttagare Inkomstar KWhMatatsIn KWhTagitsUt AndelIAnslPunkt Specifikationsnummer
526009875445385000 190101019999 2018 50078,0 88462,0 1
258655985101244000 190201019999 2018 75,0 4615,0 2
112855269388863000 190301019999 2018 16687,0 19870,0 42 3
364615095294089000 190401019999 2018 16687,0 19870,0 58 4
534980084130649000 190501019999 2018 174,0 7009,0 5
It looks like your missing the actual data itself...the top half is the description of the sender and details. And later is data section (Blankettinnehall)
So on your excel I would expect rows with columns for each header/ sender details. This may be whats missing.
You can see this if you take a sample file from them and view it in Excel.
I struggled with KU52 last year ended up doing a C# application to generate the XML file.

jBCrypt checkpw returns true even though passwords are different

I'm pretty much sure I must be doing something completely wrong, but why is this test failing for the last two assertions?
Two relatively similar, but nevertheless different Strings (basically JWT) test ok with the hashes of the other?
#Test
public void testMoreHashing() {
String longToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJCTFVCQl9BVURJRU5DRSIsInN1YiI6IkNZOXJ6VVloMDNQSzNrNkRKaWUwOWc9PSIsIm5iZiI6MTUxMzI4NzAzNCwiaXNzIjoiSVNTVUVSIiwiZXhwIjoxNTE4NDcxMDM0LCJpYXQiOjE1MTMyODcwMzQsImVtYWlsIjoiYUBiLmNvbSJ9.IYMKztYEIJxzYgHpUDhCHcG22h28OQAsMg7TEMBVYELSczeniwv8IKxgrSBub9Q0X14UT6LnQUu4yeeTofRYH2jRSwW42gfaW5uK8NJQVdluNdZwUsWHVG05gbaSM7ZeS4tH3-SVbUOO3uJ-N2sVcBF5AFLaIAu0GD9CzPU1CjYYc9JiAArztAS5j7pK-xGNTRCKvcoGLa9iG9nhvssTZkPH6kPOJj9RHFo30mgSnPIGSc6040h7n8X7LCUC4qfUe1sOknHomN_RKTQk4Q5FBL1snTyCTxcaErVwvjv__YK9FQ40pDfOboEsSk81CYW6SbqDIdVlyr09VrDzIwJpPA";
String shortToken = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJCTFVCQl9BVURJRU5DRSIsInN1YiI6IlU3bFFoV09TUDBmMDdOZ1BWTkd3d0E9PSIsIm5iZiI6MTUxMzI4NzAzNSwiaXNzIjoiSVNTVUVSIiwiZXhwIjoxNTE4NDcxMDM1LCJpYXQiOjE1MTMyODcwMzUsImVtYWlsIjoiYUBiLmNvbSJ9.";
String longTokenHash = BCrypt.hashpw(longToken, BCrypt.gensalt(13));
assertTrue(BCrypt.checkpw(longToken, longTokenHash));
String shortTokenHash = BCrypt.hashpw(shortToken, BCrypt.gensalt(13));
assertTrue(BCrypt.checkpw(shortToken, shortTokenHash));
assertFalse(longToken.equalsIgnoreCase(shortToken));
assertFalse(longTokenHash.equalsIgnoreCase(shortTokenHash));
assertFalse(longToken.contains(shortToken));
assertFalse(BCrypt.checkpw(longToken, shortTokenHash));
assertFalse(BCrypt.checkpw(shortToken, longTokenHash));
}
the used version of jBCrypt as copied from my pom.xml is
<dependency>
<groupId>de.svenkubiak</groupId>
<artifactId>jBCrypt</artifactId>
<version>0.4</version>
</dependency>
junit is version 4.12
Thanks for helping :)
as #tadman pointed out, the used blowfish algorithm is truncating passwords at 72 characters, and the differences in the used passwords only start at 79.
see also https://security.stackexchange.com/questions/39849/does-bcrypt-have-a-maximum-password-length

How to insert a string after a certain number of string characters in XQuery?

I want to insert a string (in this case, a linebreak, \L) after 25 characters into a string, but only at the next available whitespace, in order to avoid splitting words like below:
This is the example sente\L nce for you.
The correct output would be like this:
This is the example sentence\L for you.
The line break should occur approximately after 25 characters on each row, so a longer example would look like:
This is a longer example\L
for you; it actually contains\L
more than 50 characters.
What would be the simplest way to implement this in XQuery?
Here is an XSLT 2.0 solution -- one needs just convert this to XQuery:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="my:my" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:value-of select="my:splitAtWords(/*, 25, '\L
')"/>
</xsl:template>
<xsl:function name="my:splitAtWords" as="xs:string?">
<xsl:param name="pText" as="xs:string?"/>
<xsl:param name="pMaxLen" as="xs:integer"/>
<xsl:param name="pRep" as="xs:string"/>
<xsl:sequence select=
"if($pText)
then
(for $line in replace($pText, concat('(^.{1,', $pMaxLen,'})\W.*'), '$1')
return
concat($line, $pRep,
my:splitAtWords(substring-after($pText,$line),$pMaxLen,$pRep))
)
else ()
"/>
</xsl:function>
</xsl:stylesheet>
When this transformation is applied on the following XML document:
<t>This is a longer example for you; it actually contains more than 50 characters.</t>
the wanted result is produced:
This is a longer example\L
for you; it actually\L
contains more than 50\L
characters\L
.\L
I ended up using the solution proposed here:
let $text := 'This is a longer example for you; it actually contains more than 50 characters.'
let $text-output := replace(concat($text,' '),'(.{0,25}) ','$1\\L')
return $text-output
Which returns the same as result as the XSLT from #dimitre-novatchev above:
This is a longer example\L
for you; it actually\L
contains more than 50\L
characters.\L

Resources