I'm using the DOM library for JAVA and some entries XHTML encounter this problem:
[Fatal Error] tree.xml:238:185: Attribute "itemprop" was already specified for element "span".
This is the XHTML part with problems:
<span class='fn' itemprop='author' itemscope='itemscope' itemtype='http://schema.org/Person' itemprop='name'>Rodrigo</span>
Exists some option to allow duplicate attributes in DOM?
Thanks!
My understanding is that the Microdata specification only allows one itemprop per HTML element, meaning that the DOM library you're using is properly marking it as invalid markup. If you want to specify multiple values, they need to be space-separated, like this:
<span class='fn' itemprop='author name' itemscope='itemscope' itemtype='http://schema.org/Person'>Rodrigo</span>
Incidentally, the class attribute works the same way.
Related
In Firebug and other DevTools you can get the DOM properties and values corresponding to an HTML element.
How can such values be extracted using selenium-java code?
I had tried getAttribute(), but it seems to be working only for HTML attributes and not for DOM properties like "value" or "spellcheck" etc.
The reason I went for this approach is that the value associated with the <input> text field (snippet below) is run-time generated and data is bound to it using Knockout. And hence it's not possible to capture them with standard approaches like getText(), getAttribute("value"), getAttribute("text"), getAttribute("innerHTML"), getAttribute("innertext"), etc.
HTML snippet for the HTML element:
<input class="form-control" type="text" style="cursor: text" readonly="readonly" data-bind="textInput: url">
I know this is an old question but it might give someone else a hand out
Use this in the console
$$("input.form-control").value
if it returns the required you will have to execute the Javascript using WebDriver i.e.
driver.ExecuteScript("var data = arguments[0].value; return data;", (Element as RemoteWebElement)
According to the Selenium documentation, there is only the getAttribute() function, which is described as follows:
Get the value of a the given attribute of the element. Will return the current value, even if this has been modified after the page has been loaded. More exactly, this method will return the value of the given attribute, unless that attribute is not present, in which case the value of the property with the same name is returned (for example for the "value" property of a textarea element). If neither value is set, null is returned. ...
According to this, getAttribute("value") should return the DOM property value in case there is no HTML attribute named value.
If that's not the case, it may be a timing issue. I.e. the value is read by Selenium before it gets set.
In Selenium 4 use getDomAttribute() and getDomProperty().
I am using Tapestry 5.2.6, and I am trying to get rid of shape attributes on tags.
Tapestry generates tag like this :
<a shape="rect"...>
I can't find anything online so if you have any idea how to ?
Thank you.
This problem was reported in Tapestry's JIRA and resolved in Tapestry 5.3.5. The offender was the SAX parser used, which automatically appends default values defined for HTML attributes in the DTD used. A check was then introduced in org.apache.tapestry5.internal.services.XMLTokenStream class to "filter out attributes that are not present in the XML input stream, but were instead provided by DTD defaulting".
See the corresponding ticket for more details: https://issues.apache.org/jira/browse/TAP5-1976.
Unfortunately, in your case, there is no clean solution to fix that (assuming you have to work with Tapestry 5.2.6). The only way would be to make your own patch or fork of Tapestry 5.2.6 to report the correction...
I have a XSL/XML parser to produce jsp/html code.
Using MVC model I need to accees spring library in order to perform i18n translation.
Thus, given the xml
<a>
...
<country>EN</country>
...
</a>
and using <spring:message code="table_country_code.EN"/> tag, choose based on the browser language, the transalation into England, Inglaterra, etc...
However, the XSL do not support <spring:message> tag.
The idea is to have a XSLT with something like this
<spring:message code="table_country_code.><xsl:value-of select="country"/>"/>`
to have the final code <spring:message code="table_country_code.EN"/> and be recognized in the final JSP/HTML based on i18n translation.
I also tried to create the spring tag in Java when I make a parse to create the XML but I sill have the same error.
The prefix "spring" for element "spring:message" is not bound.
[EDIT]
I saw some questions here, like using bean:spring but still have the same problem.
any pointers?
XSLT has to be namespace well formed XML, so you need to declare the namespace and you can not use < in attribute values.
Spring 3 - Accessing messages.properties in jsp
suggests the namespace should be
http://www.springframework.org/tags
so presumably you want an XSLT code of
<spring:message
xmlns:spring="http://www.springframework.org/tags"
code="table_country_code.{country}"
/>
where {} is an attribute value template that evaluates the XPath country
I'm trying to do a macro on freemarker, but I'm having problems to implement css class as parameter.
My object have some default css classes and I would like to add optional classes.
<#macro Button href extra...>
<a href="${href}" class="ui-button"
<#list extra?keys as attr>
${attr}="${extra[attr]?html}"
</#list>
>Anchor Button</a>
</#macro>
1) <#Button href="link.html"></#Button>
2) <#Button href="link.html" id="button1" class="marginrightnone"></#Button>
The line 2) only is rendering the "id" parameter. If I delete class="ui-button" of the macro, then it renders correctly.
What I could to do to render two or more class parameters???
You need to construct a string containing all the class parameters and use that as the value of a single HTML class attribute in the template.
You can't have an arbitrary number of class attribute/value pairs and still be legal HTML.
The simplest that would be basically what you have now would be to create a local with the "ui-button" value in it. As you iterate over extra?keys check for a "class" key and if found, append it to the local class (along with a leading space). The template would use that constructed value:
<a href="${href}" classes="${local_classes}"
How can I check for a particular error on a JSP page and only show it when it is present.
For example I would like to check whether the following error exists using <c:if> tag and only then render it as HTML.
<form:errors path="transactionType" cssClass="error"></form:errors>
Use the <spring:hasBindErrors name="myFormBean"> tag, and inspect the page-scope errors bean.
Reference doc link
You already get this functionality with the <form:errors> tag. It only renders its contents when there is a corresponding error (based on the path attribute), so it is analogous to using a <c:if> to first check for an error.