Processing a template with thymeleaf with "utm_source" even under a href property causes a failure.
org.xml.sax.SAXParseException; lineNumber: 315; columnNumber: 126; The reference to entity "utm_source" must end with the ';' delimiter.
Does any one know a workaround for this? Since it's a like if I transform to a HTML code it fails then because there are && together.
Also, this is probably more related to SAX Parser than thymeleaf.
Escaping with & works. Example:
Your link parameters should be done like so:
<a th:href="#{${baseUrl}(param1=value1,param2=value2)}">
Source:
http://www.thymeleaf.org/doc/articles/standardurlsyntax.html
Related
In my Spring Controller I set following to my model attribute:
model.addAttribute("abc-def", "Hello World");
In my thymeleaf html I want to read the value of abc-def.
<th:block th:text="${abc-def}"></th:block>
But I get the error:
The operator 'SUBTRACT' is not supported between objects of type 'null' and 'null'
Its clear because - is an arithmetic operator. Is there a way to escape - for reading out the model value?
My advice would be: don't use variables names with dashes in them. (Would you try to define a variable int abc-def = 5; in java?)
In any case, this seems to work if you have to use it:
<th:block th:text="${#request.getAttribute('abc-def')}" />
Thymeleaf 2
Per the Expression Basic Objects section of the documentation (with more details in Appendix A), the context variables are in a #vars object. So, you can access variables with something like this:
<th:block th:text="${#vars.get('abc-def')}" />
Thymeleaf 3
As Metroids commented this all changes in Thymeleaf 3. It combines the #ctx and #vars objects, so you need to use the Context's getVariable method:
<th:block th:text="${#ctx.getVariable('abc-def')}" />
But this isn't the best plan
While certainly these will "work", having variables with punctuation in them is a bit unusual, and may confuse the next programmer to see your code. I wouldn't do it unless I had a really good reason to use that name.
I am trying to create a routine for validating xhtml documents. I use xproc which I run in Calabash. In is an xhtml document. This document may not be valid.
For testing I edit an xhtml document. I simply delete a and introduce an error. This is the error I hope to detect when I validate the document.
In order to validate I use , I supply a schema, and I output the result of the validation in a new file.
But if the input file is not valid in the first place xproc/Calabash stops. The error message is basically an error message from Saxon pointing out that the is missing. But I wanted the validation output in my output file. How do I do that?
<p:input port="source" primary="true"/>
<p:load name="xml-doc" href="'input.xhtml'"/>
<p:validate-with-xml-schema name="validate">
<p:input port="source">
<p:pipe port="result" step="xml-doc"/>
</p:input>
<p:with-option name="assert-valid" select="'false'"/>
<p:with-option name="mode" select="'lax'"/>
<p:input port="schema">
<p:document href="xhtml-schema.xsd"/>
</p:input>
</p:validate-with-xml-schema>
<p:store name="valid-store">
<p:input port="source">
<p:pipe port="result" step="validate"/>
</p:input>
<p:with-option name="href" select="'output.xml'"/>
</p:store>
From your question it's not clear what exactly is Saxon complaining about, but I assume that it cannot find the input XHTML file. You wrap the file name in single quotes in p:load/#href, which is not correct. When you use the attribute-based shortcut form for options, the value of the attribute is taken as-is and is not interpreted as an XPath expression (which is the case when you use the long p:with-option form).
Getting XML from this URL:
$xml = simplexml_load_file('http://geocode-maps.yandex.ru/1.x/?geocode=37.71677,55.75208&kind=metro&spn=1,1&rspn=1');
print_r($xml) shows that XML loaded, but xpath always returns empty array. I tried:
$xml->xpath('/');
$xml->xpath('/ymaps');
$xml->xpath('/GeoObjectCollection');
$xml->xpath('/ymaps/GeoObjectCollection');
$xml->xpath('//GeoObjectCollection');
$xml->xpath('precision');
Why I got empty array? Hope I just missing something easy.
It might be rather easy, but I guess it is also the most common mistake in the history of XML: You are forgetting namespaces!
A lot of elements in the given XML are changing the default namespace and you have to consider that in your XPath.
You can first register your namespace like so:
$xml->registerXPathNamespace('y', 'http://maps.yandex.ru/ymaps/1.x');
$xml->registerXPathNamespace('a', 'http://maps.yandex.ru/attribution/1.x');
and then you can query your data:
$xml->xpath('//y:ymaps/y:GeoObjectCollection');
I have an element whose html is like :
<div class="gwt-Label textNoStyle textNoWrap titlePanelGrayDiagonal-Text">Announcements</div>
I want to check the presence of this element. So I am doing something like :
WebDriver driver = new FirefoxDriver(profile);
driver.findElement(By.cssSelector(".titlePanelGrayDiagonal-Text"));
But its not able to evaluate the CSSSelector.
Even I tried like :
By.cssSelector("gwt-Label.textNoStyle.textNoWrap.titlePanelGrayDiagonal-Text")
tried with this as well :
By.cssSelector("div.textNoWrap.titlePanelGrayDiagonal-Text")
Note : titlePanelGrayDiagonal-Text class is used by only this element in the whole page. So its unique.
Contains pseudo selector I can not use.
I want to identify only with css class.
Versions: Selenium 2.9 WebDriver
Firefox 5.0
When using Webdriver you want to use W3C standard css selectors not sizzle selectors like you may be used to using in jquery. In your example you would want to use:
driver.findElement(By.cssSelector("div[class='titlePanelGrayDiagonal-Text']"));
From reading over your post what you should do since that class is unique is just do a FindElement(By.ClassName("titlePanelGrayDiagonal-Text"));
Also the CssSelector doesn't handle the contains keyword it was something that the w3 talked about but never added.
I haven't used css selectors, but this is the xpath selector I would use:
"xpath=//div[#class='gwt-Label textNoStyle textNoWrap titlePanelGrayDiagonal-Text']"
The css selector should then probably be something like
"css=div[class='gwt-Label textNoStyle textNoWrap titlePanelGrayDiagonal-Text']"
Source: http://release.seleniumhq.org/selenium-remote-control/0.9.2/doc/dotnet/Selenium.html
Did you ever tried following code,
By.cssSelector("div#gwt-Label.textNoStyle.textNoWrap.titlePanelGrayDiagonal-Text");
I believe using a wildcard in CSS would be more helpful. Something as follows
driver.findElement(By.cssSelector("div[class$='titlePanelGrayDiagonal-Text']");
This will look into the class attribute and see what that attribute is ending with. Since your class attribute is ending with "titlePanelGrayDiagonal-Text" string, the added '$' in the css statement will find the element and then you can perform whatever action you're trying to perform.
it seems that all entities are killed using
tags = "<p>test umlauts รถ</p>"
Nokogiri::XML.fragment(tags)
Result:
<p>test umlauts </p>
The above method calls Nokogiri::XML::DocumentFragment.parse(tags) and that methods calls
Nokogiri::XML::DocumentFragment.new(XML::Document.new, tags).
In relation to the nokogiri documentation this code will be executed:
def initialize document, tags=nil
if tags
parser = if self.kind_of?(Nokogiri::HTML::DocumentFragment)
HTML::SAX::Parser.new(FragmentHandler.new(self, tags))
else
XML::SAX::Parser.new(FragmentHandler.new(self, tags))
end
parser.parse(tags)
end
end
I think we are dealing with the XML::SAX::Parser and the corresponding FragmentHandler. Digging around the code gives no hint; which parameters do I have to set to get the correct result?
oouml is not a predefined entity in XML. If you want to allow the HTML entity references in XHTML you'd need to use a parser that read the external DTD in the doctype. This is a lot of effort; you may prefer to just use the HTML parser if you have HTML-compatible XHTML with entity references.