I am wondering if there is any chance to create a wildcard attribute list in xhtml. E.g.
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [
<!ATTLIST a tooltip CDATA #IMPLIED>
<!ATTLIST a tooltip-align (top|bottom|right|left) #IMPLIED>
]>
Instead of "a" I would like to add these two attributes to all elements. Any idea? Thanks
No. The XHTML DTD works around this with entity declarations, something like this (simplified):
<!ENTITY % coreattrs
"id ID #IMPLIED
class CDATA #IMPLIED
style %StyleSheet; #IMPLIED
title %Text; #IMPLIED"
>
<!ELEMENT a %a.content;>
<!ATTLIST a
%coreattrs;
href %URI; #IMPLIED
... etcetera ...
>
Related
I need yes or yes XHTML 1.1 strict, no html5.
That is the code of my doc.xhtml:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html SYSTEM "prueba.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es">
<head><meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Galaxy</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
</head><body><div>
<nav>
<esphere>
<planet>Jupiter!</planet>
</esphere>
</nav>
</div>
</body></html>
That is the code of my DTD:
<!ENTITY % InlPhras.class "| esphere | nav | planet ">
<!ELEMENT esphere ANY>
<!ELEMENT nav ANY>
<!ELEMENT planet ANY>
<!ENTITY % html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
%html;
The combination of this two files, (the two codes together) run fine in validator W3C, but really this is a correct method to add elements to XHTML 1.1 strict?
How I can define best the element planet?
(by example weight, radio, gravity...)
Aditionally, if I begin the page without DIV element, then validator fail.
Why?
Why is a requeriment begin the document XHTML with DIV ?
Can someone explain why the Javascript test function works even though the XQuery function is declared prior to including the script in the HTML?
test.js
function test(){
alert('from test');
}
index.xqy
declare function local:test(){
for (: do something :)
return (
<script>
test("Testing...")
</script>
)
};
xdmp:set-response-content-type("text/html; charset=utf-8"),
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
</head>
<body>
<script type="text/javascript" src="test.js"></script>
{
local:test()
}
</body>
</html>
All the XQuery code in index.xqy is executed server-side, so local:test() is called and evaluated before it gets to the browser. The first thing the browser sees is the Doctype declaration, and it evaluates the page with the result of local:test() already rendered.
I'm trying to include a long string in an external file using the following syntax:
<fx:String id="myText" source="examples/text.txt" />
But it's generating an error:
1084: Syntax error: expecting identifier before rightparen.
Is there something I'm missing?
I've seen similar for embedding a text file using ActionScript but I would like to embed a string value using MXML.
I've found this example on Flex help docs:
<fx:String id="myStringProperty1" source="./file"/>
I can't see anything that I'm doing differently.
OK I found the cause. In my external file I have a few curly braces. The compiler is getting hung up on those.
Here is the contents of my external file:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<style type="text/css" media="screen">
html, body {
height:100%;
}
</style>
</head>
</html>
The part where it has body { height:100% } it is interpreting it as data binding. Here is the generated ActionScript:
result[1] = new mx.binding.Binding(this,
function():String
{
var result:* = "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\"> \n <head>\n <style type=\"text/css\" media=\"screen\"> \n html, body " + (
height:100%;
) + "\n </style>\n </head>\n</html>";
return (result == undefined ? null : String(result));
},
null,
"HTML"
);
As you can see it thinks I'm using data binding between the curly braces. Since I'm not, it's throwing an error because "height:100%" is out of context where it's being used.
I think I will have to try a different method to embed this text. It seems to be fine if I use this but I rather not:
<fx:String id="HTML">
<![CDATA[<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<style type="text/css" media="screen">
html, body {
height:100%;
}
</style>
</head>
</html>]]>
</fx:String>
UPDATE!!!
I WAS WRONG! It is possible. I have to escape at least the opening curly brace and then it works.
Contents of file that works:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<style type="text/css" media="screen">
html, body \{
height:100%;
\}
</style>
</head>
</html>
I am downloading part of an HTML page by:
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open('https://example.com/index.html'))
wiki = doc./('//*[#id="wiki"]/div[1]')
and I need the stylesheets in order to display it correctly. They are included in the header like so:
<!DOCTYPE html>
<html lang="en" class="">
<head>
...
<link href="https://example.com/9f40a.css" media="all" rel="stylesheet" />
<link href="https://example.com/4e5fb.css" media="all" rel="stylesheet" />
...
</head>
...
and their naming can be changed. How do I parse/download local copies of the stylesheets?
Something like this:
require 'open-uri'
doc.css("head link").each do |tag|
link = tag["href"]
next unless link && link.end_with?("css")
File.open("/tmp/#{File.basename(link)}", "w") do |f|
content = open(link) { |g| g.read }
f.write(content)
end
end
I'm not a ruby expert but you can go over following steps
You can use .scan(...) method provided with String type to parse and get the .css file names. The scan method will return you an array stylesheet file names. Find more info on scan here
Then download and store the files with Net::HTTP.get(...) an example is here
I am trying to validate my XHTML Frameset page but I get the following errors from the W3C Markup Validation Service:
Missing "charset" attribute for "text/xml" document.
Line 1, Column 41: parsing XML declaration: '?>' expected
I have the following heading in my file:
<?xml version = "1.0" encoding = "utf-8" charset=utf-8?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
I changed the heading as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
I added the following meta tag in between the head tags:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
No more errors or warnings.