xslt namspace related to copying some elements - xslt-2.0

So, I have a stylesheet that spends most of its time transforming elements from 'namespace a' to the xhtml namespace.
In one particular case, however, I want to allow the input vocabulary to include any xhtml element. From a schema standpoint, I've added an <xs:any namespace="...."/> for the xhtml namespace.
It looks like:
<btml:html-noscript xmlns="http://www.w3.org/1999/xhtml">
<div style="display:inline;">
<img height="1"
width="1"
style="border-style:none;"
alt=""
src="http://www.googleadservices.com/pagead/conversion/1070015830/?label=FoKlCKDxiAIQ1sqc_gM&guid=ON&script=0"/>
</div>
</btml:html-noscript>
The stylesheet uses xsl:copy-of to copy the children of the passthrough element into the output.
Saxon-B, which I am using (last release), seems sort of stupid about the namespaces. Even though the target namespace of the entire output document is the xhtml namespace, the output looks like:
<noscript>
<div xmlns:btml="http://www.basistech.com/2010/btml/"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
style="display:inline;">
<img height="1"
width="1"
style="border-style:none;"
alt=""
src="http://www.googleadservices.com/pagead/conversion/1070015830/?label=FoKlCKDxiAIQ1sqc_gM&guid=ON&script=0"></img>
</div>
</noscript>
Note the pointless prefixes, instead of just putting out <div ...>. Note that the document element of the whole business ('html') defines xmlns="ttp://www.w3.org/1999/xhtml".
Is there any way to neaten this up?

Try whether doing <xsl:copy-of select="node()" copy-namespaces="no"/> helps (see http://www.w3.org/TR/xslt20/#copy-of). If not then please post complete samples of XML input, and XSLT stylesheet allowing us to reproduce the problem, your snippets so far do not explain where for instance the xmlns:xhtml="..." in the result snippet on the div element comes from.

From http://www.w3.org/TR/xml-names/#scoping
The scope of a namespace declaration
declaring a prefix extends from the
beginning of the start-tag in which it
appears to the end of the
corresponding end-tag, excluding the
scope of any inner declarations with
the same NSAttName part. In the case
of an empty tag, the scope is the tag
itself.
For your case, it means that "http://www.basistech.com/2010/btml/" and "http://www.w3.org/1999/xhtml" namespace URIs bound to btml an xhtml prefixes are in scope for your div element unther "http://www.w3.org/1999/xhtml" default namespace.
Of course, as suggested by #Martin Honnen's answer xsl:copy-of/#copy-namespaces with "no" as value will strip in scope namespace not actually used (i.e. in this element or its attribute's names).

Related

What happens if different region attribute values are specified on parent and child?

Suppose we have the following TTML document:
<tt xml:lang="en" xmlns="http://www.w3.org/ns/ttml" xmlns:tts="http://www.w3.org/ns/ttml#styling">
<head>
<layout>
<region xml:id="a"/>
<region xml:id="b"/>
</layout>
</head>
<body>
<div region="a">
<p region="b">abc</p>
</div>
</body>
</tt>
According to 9.3.2 Intermediate Synchronic Document Construction, what visual marks will be produced by regions a and b?
At first I was expecting a to produce nothing and b to produce abc, but the specification seems to contradict this implying that the anonymous span abc will be pruned (directly or indirectly) both when evaluating region a and b, which seems a bit counter-intuitive.
The algorithm prunes the content and nothing is displayed. This is captured on the W3C TTWG Issue tracker in Issue-341.
Why would you author a document with this behaviour though - I mean, what would you intend to happen? Under which conditions would you not achieve the same thing simply by removing the region reference from the div? I ask for interest - if there's a use case here then we can use it to help drive the spec development in TTML.

Repeat over contents, polymer dart

I want to loop over all children of a custom polymer element - for instance, to place each child in a new div.
<template repeat="{{child in children}}">
<div>
{{child}}
</div>
</template>
When I try this, I get the toString() version of child, rather than the element itself. Is there a way to reference the element itself inside the repeat, rather than the result of its toString() method?
Update
A ready-to-use element for Dart Polymer 1.0 is bwu-bind-html
This is not supported. Moustache binding can't insert HTML.
What you can do though is to use a Polymer element that provides that feature.
Please have look at my answer to HTML Tags Within Internationalized Strings In Polymer.dart <safe-html>.
With this element your code would look like:
<template repeat="{{child in children}}">
<div>
<safe-html model="{{child}}"></safe-html>
</div>
</template>
You might need to customize the NodeValidator construction which defines what kind of Elements are allowed to be added.
This feature might pose security risks (XSS) and is therefore not included in Polymer by default.

Dart: dynamic redirection without reload

Please note I'm not interested in a Polymer-, Angular- or route-based solution here. I'm trying to learn "pure" Dart here, and while I'll likely switch to using one of those frameworks down the road, I need to have a good understanding of the fundamentals first.
In Dart, is it possible to download a whole bunch of HTML "snippets" (see below) all at once (at app startup), and then load them into the browser (either the entire window or just inside a particular <div> element, etc.) dynamically?
For instance, my HTML file might have a <div> element:
<body>
<!-- lots of HTML -->
<div id="container"></div>
<!-- more HTML -->
</body>
And I would like to download two "snippets" (DOM subtrees, HTML templates) of HTML, and dynamically load either one of them into the container div tag. Perhaps one of the snippets looks like this:
<h1>I'm Snippet #1!!!</h1>
<input type="button" name="redPillButton" value="Red Pill!" />
And another snippet my look like:
<h1>I'm Snippet #2!!!</h1>
<input type="button" name="bluePillButton" value="Blue Pill!" />
Can the two snippets be inside their own HTML file, or do I have to put them inside one big file and extract out the "snippet" that I want to load? Either way, how do I accomplish this in a Dart web app?
You can keep each parts in their own file and load them like that :
HttpRequest.getString("part.html").then((html) {
querySelector('#container').innerHtml = html;
});

Thymleaf: Adding attribute in div tag

I need to add an attribute in with in div tag in thymleaf as follows
<div class="mp_snippet_address" itemscope itemtype="http://schema.org/LocalBusiness">
the problem is i could not define the itemscope in div tag
The standard HTML parser in Thymeleaf is a very strict XML parser. You can switch to the less-strict LEGACYHTML5 template mode (then include the nekoHTML 1.9.15+ as a dependency), which allows for 'boolean attributes', but the output may be slightly different than the input templates as I think it performs some kind of tag balancing to massage HTML5 into being well-formed XML.
Support for HTML as per the HTML spec is on the cards for Thymeleaf 3.0, but that version is still a very very very long way away.

html simple anchor link doesn't work in opera

At first If something similiar to this already has been asked, I am sorry, but that is my first question here and i didn't find anything that could had helped.
Since i dont know if it's important, my doctype is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd">
<div id="container"> /* container i which everything is nested */
<div id="header">
</div>
<div id="Navigation">
<a onmouseover="Bildwechsel('Galerie','HGalerie.png');"onmouseout="Bildwechsel('Galerie','Galerie.png');" href="Galerie.htm"><img alt="Navigation" src="Galerie.png" name="Galerie" /></a> //one of the links which is causing trouble
</div>
<div id="content"></div>
</div>
and that is the mouseover function (hope you don't mind the names, i'm German):
function Bildwechsel(Bild, BildSource) {
document.images[Bild].src = BildSource; /* function i use to change pictures on mouseover */
}
In my header, i have also included two versions of jQuery (that is because a plugin needs an older version to work properly) and lightbox v2. I have implemented them with var something=jQuery.noConflict();, also inserting true in one of these declarations because otherwise it wouldn't work but since everything works fine, I think there shouldn't be a problem.
My problem know is that when i click the link with href="Galerie.htm" every browser I mentioned at the beginning excluding opera (I am using version 11.62) is navigating to Galerie.htm. But in Opera it's like the Browser's only refreshing the site, so he always stays on the same page no matter what link i click. Maybe good to know: When i right-click on the link and open it in a new tab, everything works fine.
And the second question is: Although i know what doctypes are good for, how do i know which one is best to use in my case? i already did check my html markup, getting about 50 results(?) with errors like :link rel="stylesheet" type="text/css" src="something.css" > missing slash between [...] .css" and >, but when i look it up in selfhtml it's written that way. I know that i depends on the doctype if the slash is needed or not ,but do i have to look every single slash up or is it not that important? If yes how can i achieve a valid html with 0 errors?
Since I always thought a (anchor?) links are the last thing i will have problems with I have really no clue whats going on here.
Any help would be appreciated ;)
without firing up Opera and playing with all this myself.. first, in that link you need a space between your onmouseover and onmouseout attributes.
e.g.
<a onmouseover="Bildwechsel('Galerie','HGalerie.png'); "onmouseout="Bildwechsel('Galerie','Galerie.png');" href="Galerie.htm"><img alt="Navigation" src="Galerie.png" name="Galerie" /></a> <!-- btw, "//" starts a javascript comment, but not so in HTML. //one of the links which is causing trouble -->
Does that help?

Resources