Marking up citations in HTML - xhtml

Is there a somewhat standardized way to semantically mark up citations in HTML? I know that when I'm citing from a website i can do:
<q title="Article by John" cite="http://example.com/article">quoted text...</q>
But I was rather thinking something a bit more precise, maybe using RDFa and Dublin Core. Along the lines of:
<q cite="http://example.com/article">quoted text...</q>
<span xmlns:dc="http://purl.org/dc/elements/1.1/" about="#berkman">
<cite property="dc:title">Find It Fast: How to Uncover Expert Information on Any Subject</cite>
<span property="dc:creator">Berkman, R. I.</span>
<span property="dc:date">1994</span>
<span property="dc:publisher">New York: HarperPerennial</span>
<span property="dc:type">book</span>
</span>
Then I could run some Javascript or XSLT over it to display the citation as a hover-text or footnote or something (HTML5 recommendation on footnotes). But this way seems to be rather loose on semantics. Isn't there a smart way to associate the quoted text (in the q tag) with an RDF triple? Like:
"quoted text..." voc:isQuotedFrom _b1.
_b1 dc:title "Find it Fast";
dc:creator "Berkman, R. I.".
I've stubled over BibTeXML and a proposed Citation microformat but they (as well as all usages of Dublin Core I've seen) always seem to focus on the metadata of a specific book (as it might appear in a bibliography) and not on how to mark up a citation and reference it to a book.
Any thoughts or tips appreciated, thanks.

Use the BIBO Ontology - it has all the terms you want:
http://bibotools.googlecode.com/svn/bibo-ontology/trunk/doc/index.html
In particular:
bibo:citedBy
bibo:cites
bibo:Quote
RDF doesn't support literals as subjects.
So in the example above I would recommend the following, based on the new RDFa-Core Specification:
<div vocab="http://purl.org/ontology/bibo/" typeof="Quote">
<span rel="cites" resource="http://mybookstore.com/books#berkman"></span>
<q cite="http://example.com/article" property="shortDescription">quoted text...</q>
</div>
<span about="http://mybookstore.com/books#berkman" typeof="Book" prefix="dc: http://purl.org/dc/elements/1.1/" vocab="http://purl.org/ontology/bibo/">
<cite property="dc:title">Find It Fast: How to Uncover Expert Information on Any Subject</cite>
<span property="dc:creator">Berkman, R. I.</span>
<span property="dc:date">1994</span>
<span property="dc:publisher">New York: HarperPerennial</span>
</span>
This would resolve to the following rdf:
#prefix dc: <http://purl.org/dc/elements/1.1/> .
#prefix bibo: <http://purl.org/ontology/bibo/> .
#prefix mybooks: <http://mybookstore.com/books#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
_:b1 rdf:type bibo:Quote;
bibo:cites mybooks:berkman;
bibo:shortDescription "quoted text...".
mybooks:berkman rdf:type bibo:Book;
dc:title "Find It Fast: How to Uncover Expert Information on Any Subject";
dc:creator "Berkman, R. I.";
dc:date "1994";
dc:publisher "New York: HarperPerennial".

Some of it is stored in meta-tags in the header.
<meta name="author" content="Hege Refsnes" />
and
<meta name="revised" content="Hege Refsnes, 23/10/2011" />
both are copy/paste from w3cschools on page on meta tags
There are other commonly used ones that are not in the w3c specification. I'm not sure if there is a list anywhere.
additionally if you decide to use html5 there are new tags and attributes for that. some of the tags are address, cite, details, summary
Another feature of html5 that you can use in xhtml (although it wont validate in xhtml) is using custom attributes. In html5 you should start them with data-yourAttributName just in case yourAttributeName gets used in later versions of html.
E.G. <p data-date='13MAR2012'></p>

Related

Incorrect behaviour of Google Translation API with notranslate tags

Google Translate API allows indicating chunks of text that should not be translated with
<span translate='no'>Skip this text while translating</span>
In some cases there is an incorrect behaviour with non-translate tags, that causes the translation API to omit one of the words and to duplicate the non-translate tag. Input of the translation API:
0c40152c asdasd alsdls3 ec3f297a <span translate="no">AAAAA123AAAA</span> Nov 30 translate
When translating from Italian to English (not sure if the language matters), the following result is returned:
0c40152c asdasd alsdls3 ec3f297a <span translate="no">AAAAA123AAAA</span> Nov 30 <span translate="no">AAAAA123AAAA</span>
Please note that the 'translate' at the end of the text is substituted with the non-translate tag.
This issues are present if instead of <span translate='no'> I use the alternative syntax: <span class='notranslate'>.
Is this a known bug ? Does it have a sensible workaround ?
Is this a known bug?
Yes: https://issuetracker.google.com/issues/121076288
Translation problem with notranslate class in span tag
Problem you have encountered:
The translation API gives wrong results translating from german to arabic
German text:
QANTARA Migration - Kostenfreie Erstprüfung Ihrer Chancen für die erfolgreiche Immigration nach Deutschland
Arabic translation:
QANTARA Migration - إجراء فحص أولي مجاني لفرص نجاح QANTARA Migration إلى ألمانيا
What you expected to happen:
Correct translation without doubling the span with notranslate - this was doubled in arabic translation as you can see
There are also a few others that seem related, like https://issuetracker.google.com/issues/74168658 and https://issuetracker.google.com/issues/35902695.
Does it have a sensible workaround?
Only hacky ones, I'm afraid.
The easiest workaround is just to replace such sections with a token, like a unique number or url that Translate is smart enough not to touch, translate, then swap the original string back in.
A more general solution is to use something like ModelFront (full-disclosure: I work there) to detect errors, and do something only in those cases.
It seems like you have specified Italian as input language, but there are very few words in the text which can be translated (for example “translate”) and they are not recognised in the source language.
This can derivate in issues with the translation algorithm, which seems to be the case here.
A workaround would be setting the source language to get automatically detected by the API and checking the confidence value:
The confidence value is an optional floating point value between 0 and
1. The closer this value is to 1, the higher the confidence level for the language detection. This member is not always available
If the confidence value is high enough for your needs, it will try to detect the appropriate source language to translate from.
Another workaround could be adding more words to the text so the algorithm has more data to work with. I have tested the API with the same input as you describe but adding a few more words. The result output is the expected.

How can I format date in Odoo 10 QWeb report?

t-field-option is not working.
I have tried
<span t-field="o.date_invoice" t-field-options='{"format": "MM/dd/yyyy"}'/>
Instead of using
<span t-field="o.date_invoice" t-field-options='{"format": "MM/dd/yyyy"}'/>
use
<span t-field="o.date_invoice" t-options='{"format": "MM/dd/yyyy"}'/>
Hope that helps!
For those who arrive here from search engines, you can control display of date in form fields using widgets.
<field name="date_planned" widget="date"/>
or,
<field name="date_planned" widget="datetime"/>
In v12, the date/datetime fields are python date/datetime objects and not string representations. The following python formatting will work in v12 reports:
<span t-esc="o.date_invoice.strftime('%m/%d/%Y')"/>
https://www.odoo.com/groups/technical-62/technical-56392463
To display localized date strings. Try the following:
<span t-field="o.date_invoice" t-options="{"widget": "date"}" />
To delete the time section:
<span t-field="o.date_invoice" t-field-options='{"widget": "date"}'/>
Use t-field-options instead of t-options
Do not change the position of the quotes in t-field-options
This code respects the format date according to lang/country.
Try this.
<span t-esc="datetime.datetime.strptime(o.sale_id.confirmation_date, '%Y-%m-%d %H:%M:%S').strftime('%B %d,%Y')"/>
My Output is: May 28,2018
According to my experience, you have used the correct way to format Qweb date, but sometimes there is problem in other thing and odoo gives error somewhere else. Hope trying this code may be helpful.
<span t-field="o.date_order" t-field-options='{"format": "d MMMM y"}'/>
also use this code
<span t-field="o.date_order" t-field-options="{'format': 'yyyy-MM-dd'}" />
You can also do one thing as formatting the date variable in the model itself and then show it on your QWeb report.

selenium xpath to fetch the value of element which has no id associated to it

I wanted to fetch the value 606 from the following code for selenium
<div class="price pad-15 per-person budget-pp marg-left-10 ">
<span>From</span>
<h2 class="size-28 dis-inblock">
<span class="size-22">£</span>
606
</h2>
<span>Per person</span>
</div>
Can anyone please help me with identifying xpath for the value 606. Thanks in advance.
XPath for element that contains 606 is:
//h2[span[text()="£"]]
You can fetch value with appropriate method in your programming language (like .get_attribute("text") or .text in Python')
Let me know in case of any issues
//div/h2/text() here is enough.
//text()[. = '606'] would be too (but I doubt it's what you require here!)
You can use below cssSelector as well :-
div.price.per-person > h2
(Assuming you're using Java) Now you can use WebElement#getText() to fetching the desired text after locating element using above selector, this would fetch text as £606, you can use some programming stuff to omit £ and get actual value which you want.

How can I use custom classes in chapter titles with Asciidoc epub3 converter?

In the adoc file I define a chapter header like:
== [big-number]#2064# Das Spiele-Labor
For HTML that translates to
<span class="big-number">2064</span>
For the epub-Version, converted with asciidoctor-epub, apparently the class is omitted. The code line in the converter.rb:
<h1 class="chapter-title">#{title_upper}#{subtitle ? %[ <small class="subtitle">#{subtitle_formatted_upper}</small>] : nil}</h1>
(/var/lib/gems/1.9.1/gems/asciidoctor-epub3-1.5.0.alpha.7.dev/lib/asciidoctor-epub3/converter.rb)
How can I get the class information over to the chapter-title to format the first number in a special way?
Or is there another way to solve this? (The first number of the chapter title should be large and CSS hasn't got a 'first-word' attribute)

How to replace a specific node with XQuery

I want to replace .<br /> with .<p/> or other tags. And I want to keep my text and other tags unchanged. For example:
<div class="page">
<div class="text">
adsdfasdf<br/>sadasdsafg<br/>kkot.<br/>
<div class="pagenumber">3</div>
</div>
</div>
To solve the question in your title (finding it), find all text nodes which end with a dot, get the first following sibling (if looking for the next following node we would also return nodes like <div>foobar.</div><br/>) and test if it is a <br/> node (in this case, only test the name, I'm not checking for emptiness here).
//text()[ends-with(., '.')]/following-sibling::node()[1]/self::br
Renaming the node - what you asked for in your question body - works like this:
rename node //text()[ends-with(., '.')]/following-sibling::node()[1]/self::br as 'p'
Renaming of course requires XQuery Update. Only finding that node also works with any XQuery 1.0 and even XPath 2.0 processors.

Resources