parsing-microformats: Difference between revisions

From Microformats Wiki
Jump to navigation Jump to search
No edit summary
(→‎Parsing class values: minor corrections to care must be taken list)
 
(15 intermediate revisions by 7 users not shown)
Line 1: Line 1:
[[http://deathsynth.125mb.com/lib/resta-cumm/ resta cumm e]] [[http://knuckleslive.siteburg.com/styles/giochi-sims.htm giochi sims]] [[http://kiushapo.siteburg.com/golf-.htm golf 2 0 sportline tdi]] [[http://nadz0r.siteburg.com/web/auto-usate.htm auto usate bmw repubblica di san marino]] [[http://arianess.siteburg.com/html/milly-d.htm milly d abraccio]] [[http://badanglican.50webs.com/directory/principessa/ principessa 2323]] [[http://nadz0r.siteburg.com/web/sapphire-atlantis.htm sapphire atlantis]] [[http://cindynmu.125mb.com/content/fasten-furios/ fasten furios]] [[http://nonkormist.50webs.com/content/prima-prova/ prima prova analisi di un testo non lett]] [[http://badanglican.50webs.com/directory/print-server/ print server usb netgear]] [[http://cindynmu.125mb.com/content/expert-somma/ expert somma]] [[http://residentra.125mb.com/pronto-amore/ pronto amore]] [[http://badanglican.50webs.com/directory/ha/ ha]] [[http://erdwolftvl.siteburg.com/data/allinwonder-radeon.htm allinwonder radeon 9800]] [[http://cindynmu.125mb.com/content/usb-lettore4/ usb lettore floppy disk mac]] [[http://cindynmu.125mb.com/content/calabresi/ calabresi]] [[http://knuckleslive.siteburg.com/styles/occhiali-moschino.htm occhiali moschino]] [[http://residentra.125mb.com/gr3/ gr 625]] [[http://chili93-93.cafe150.com/new/teoria-del.htm teoria del capitale umano]] [[http://nonkormist.50webs.com/content/fifa-manager/ fifa manager 2003]] [[http://deathsynth.125mb.com/lib/dlink-ant4/ dlink ant241800]] [[http://badanglican.50webs.com/directory/marron-this/ marron this love]] [[http://arianess.siteburg.com/html/hs-w.htm hs 37w]] [[http://residentra.125mb.com/www-nuotomaster/ www nuotomaster it]] [[http://cindynmu.125mb.com/content/www-altavista5/ www altavista ity]] [[http://knuckleslive.siteburg.com/styles/www-google.htm www google c0m pe]] [[http://tersky.netfirms.com/telefoni-bluetooth/ telefoni bluetooth]] [[http://jazzy-joe.netfirms.com/view/divano-classico/ divano classico]] [[http://residentra.125mb.com/meteo-chioggia/ meteo chioggia]] [[http://badanglican.50webs.com/directory/rex-forni/ rex forni a gas per incasso]] [[http://redpatience.netfirms.com/resources/oryon-bird.htm oryon bird]] [[http://nonkormist.50webs.com/content/spirito-santo/ spirito santo cuore dell umanita]] [[http://residentra.125mb.com/sony-vaio133/ sony vaio 13 3]] [[http://cindynmu.125mb.com/content/foto-calciatori4/ foto calciatori piu belli del mondo]] [[http://nadz0r.siteburg.com/web/hp.htm hp 90]] [[http://residentra.125mb.com/www-vree/ www vree sex hot and action women live]] [[http://cindynmu.125mb.com/content/jordan-combined/ jordan combined hc mpg]] [[http://chrystia.50webs.com/blog/lettori-mp/ lettori mp3 portatili 512 mb]] [[http://arianess.siteburg.com/html/batista.htm batista]] [[http://cindynmu.125mb.com/content/shoes/ shoes]] [[http://yoshimi.50webs.com/resources/ragazze-in/ ragazze in mini gonne]] [[http://valuevin.siteburg.com/view/talens-jenaro.htm talens jenaro]] [[http://chrystia.50webs.com/blog/da-solo/ da solo sto]] [[http://oh-so-jackass.netfirms.com/articles/khol/ khol]] [[http://arianess.siteburg.com/html/compass-com.htm compass com]] [[http://burnmasterflex.netfirms.com/free-usher1.htm free usher yeah download]] [[http://frellingsm.125mb.com/description/dvi-ingresso/ dvi ingresso]] [[http://residentra.125mb.com/foto-hard39/ foto hard trans]] [[http://oh-so-jackass.netfirms.com/articles/rav-a/ rav4 a roma]] [[http://chili93-93.cafe150.com/new/gramolata.htm gramolata]] [[http://nonkormist.50webs.com/content/www-porno/ www porno hotmail]] [[http://chili93-93.cafe150.com/new/progetto-teatro.htm progetto teatro scuola]] [[http://kiushapo.siteburg.com/la-teresina.htm la teresina]] [[http://badanglican.50webs.com/directory/delibes-miguel/ delibes miguel]] [[http://yoshimi.50webs.com/resources/materiali-di/ materiali di saldatura]] [[http://chili93-93.cafe150.com/new/converter-mp.htm converter mp3]] [[http://nadz0r.siteburg.com/web/lucille-ball.htm lucille ball]] [[http://nadz0r.siteburg.com/web/campanile-hotel.htm campanile hotel nice]] [[http://filegedhiel.netfirms.com/resources/obstacle-golf.htm obstacle golf]] [[http://yoshimi.50webs.com/resources/candle-in/ candle in wind]] [[http://nonkormist.50webs.com/content/change-for/ change for me]] [[http://nonkormist.50webs.com/content/franki-fuck/ franki fuck it]] [[http://residentra.125mb.com/www-medicare/ www medicare gov]] [[http://nonkormist.50webs.com/content/muzyka-mp/ muzyka mp3]] [[http://redisoid.netfirms.com/blog/www-sv/ www sv nufringen de]] [[http://chili93-93.cafe150.com/new/telecomando-per.htm telecomando per canon]] [[http://chrystia.50webs.com/blog/michel-platini/ michel platini]] [[http://deathsynth.125mb.com/lib/sony-141/ sony  dcrhc22]] [[http://residentra.125mb.com/tagli-moderni/ tagli moderni]] [[http://badanglican.50webs.com/directory/mappe-concettuali/ mappe concettuali per maturita]] [[http://residentra.125mb.com/gps22/ gps 5]] [[http://yoshimi.50webs.com/resources/nikon/ nikon 4]] [[http://natashariard.netfirms.com/lavatrice-lavasciuga2/ lavatrice lavasciuga 4 5]] [[http://cindynmu.125mb.com/content/arredamento-negozi4/ arredamento negozi franchising]] [[http://erdwolftvl.siteburg.com/data/armando-spagnolo.htm armando spagnolo]] [[http://nadz0r.siteburg.com/web/viaggio-senza.htm viaggio senza vento]] [[http://nonkormist.50webs.com/content/claudia-/ claudia 21 da ru]] [[http://nonkormist.50webs.com/content/breitinger-johann/ breitinger johann jakob]] [[http://nonkormist.50webs.com/content/gonna-fly/ gonna fly now]] [[http://chili93-93.cafe150.com/new/liteon-sx.htm liteon 852sx]] [[http://cindynmu.125mb.com/content/avventure-magiche/ avventure magiche]] [[http://thezekie.at.tut.by/data/ragazza-ginevra.htm ragazza ginevra]] [[http://cindynmu.125mb.com/content/bluetooth-gps11/ bluetooth gps sirf]] [[http://chrystia.50webs.com/blog/the-sum/ the sum of all fears]] [[http://deathsynth.125mb.com/lib/geforce-agp2/ geforce agp 256]] [[http://chili93-93.cafe150.com/new/don-t.htm don t stop me now]] [[http://cindynmu.125mb.com/index0_500.html page]] [[http://residentra.125mb.com/castleween/ castleween]] [[http://yoshimi.50webs.com/resources/andare-a/ andare a cavallo]] [[http://badanglican.50webs.com/directory/zoom-sigma/ zoom sigma 70300]] [[http://yoshimi.50webs.com/resources/recorder-dvd/ recorder dvd sony]] [[http://yoshimi.50webs.com/resources/luca-argentiero/ luca argentiero]] [[http://frellingsm.125mb.com/description/televisore-grundig/ televisore grundig]] [[http://yoshimi.50webs.com/resources/beni-strumentali/ beni strumentali]] [[http://redisoid.netfirms.com/blog/gta-san25/ gta san andreas p er pc]] [[http://nadz0r.siteburg.com/web/rtl-it.htm rtl it]] [[http://arianess.siteburg.com/html/video-sabrina.htm video sabrina salerno]] [[http://beat-poets.netfirms.com/data/lettori-multimediali5/ lettori multimediali portatili]] [[http://exler-rss.netfirms.com/blog/breath-easy7.htm breath easy versione italiana]] [[http://erdwolftvl.siteburg.com/data/lindy-alimentatore.htm lindy alimentatore]] [[http://titinthewi.freehostia.com/tom-tom34.htm tom tom gps mobile]] [[http://titinthewi.freehostia.com/sborra-piedi.htm sborra piedi]] [[http://nicole-kid1.freehostia.com/plextor-/ plextor  px716a]] [[http://my500px.jino-net.ru/topic/nouvelle-vague/ nouvelle vague]] [[http://snmnstrz21.jino-net.ru/small/campeones.htm campeones]] [[http://snmnstrz21.jino-net.ru/small/nick-bug.htm nick bug]] [[http://darkforest214.jino-net.ru/content/black-hawk1/ black hawk down ps2]] [[http://snmnstrz21.jino-net.ru/small/tastiere-rf.htm tastiere rf benq]] [[http://darkforest214.jino-net.ru/content/stampanti-laser19/ stampanti laser fronteretro samsung]] [[http://darkforest214.jino-net.ru/content/esprinet/ esprinet]] [[http://nicole-kid1.freehostia.com/monte-baldo/ monte baldo]] [[http://snmnstrz21.jino-net.ru/small/parma-hotel.htm parma hotel]] [[http://my500px.jino-net.ru/topic/intel-d/ intel d]] [[http://helent.freehostia.com/small/viaggi-omaggio.htm viaggi omaggio]] [[http://sugarbear2.freehostia.com/blog/tom-bluetooth/ tom bluetooth gps]] [[http://my500px.jino-net.ru/topic/parrano/ parrano]] [[http://nicole-kid1.freehostia.com/eddy-what/ eddy what]] [[http://darkforest214.jino-net.ru/content/carroll-oconnor/ carroll oconnor]] [[http://arqenelk.freehostia.com/library/aps/ aps]] [[http://helent.freehostia.com/small/techna.htm techna 2004]] [[http://sugarbear2.freehostia.com/blog/http-www23/ http www china com]] [[http://helent.freehostia.com/small/grand-prix3.htm grand prix4]] [[http://nicole-kid1.freehostia.com/www-enpals/ www enpals it]] [[http://nicole-kid1.freehostia.com/monitor-belinea3/ monitor belinea 19 crt]] [[http://my500px.jino-net.ru/topic/flash-cards/ flash cards]] [[http://helent.freehostia.com/small/telefonino-symbian.htm telefonino symbian]] [[http://sugarbear2.freehostia.com/blog/foto-di110/ foto di shakira]] [[http://helent.freehostia.com/small/trulala.htm trulala]] [[http://my500px.jino-net.ru/topic/gemme/ gemme]] [[http://darkforest214.jino-net.ru/content/vodafon-meg/ vodafon meg]] [[http://my500px.jino-net.ru/topic/foto-ragazze7/ foto ragazze lesbiche]] [[http://nicole-kid1.freehostia.com/treken/ treken]] [[http://my500px.jino-net.ru/topic/marco-rossi1/ marco rossi picchia duro in video]] [[http://darkforest214.jino-net.ru/content/scopa-per/ scopa per parquet]] [[http://nicole-kid1.freehostia.com/vassoio/ vassoio 250]] [[http://nicole-kid1.freehostia.com/cybershot-v/ cybershot v3]] [[http://arqenelk.freehostia.com/library/letras-goticas/ letras goticas]] [[http://arqenelk.freehostia.com/library/il-signor2/ il signor max]] [[http://titinthewi.freehostia.com/codici-di8.htm codici di sblocco cellullari 3]] [[http://arqenelk.freehostia.com/library/skunk-anansie1/ skunk anansie]] [[http://my500px.jino-net.ru/topic/esecuzioni-in1/ esecuzioni in irak]] [[http://snmnstrz21.jino-net.ru/small/web-sites.htm web sites]] [[http://darkforest214.jino-net.ru/content/asus-deluxe1/ asus deluxe p5rd1v]] [[http://snmnstrz21.jino-net.ru/small/mazda-mazda1.htm mazda mazda2]] [[http://arqenelk.freehostia.com/library/un-colpo1/ un colpo di fulmine]] [[http://snmnstrz21.jino-net.ru/small/zoom-nikkor.htm zoom nikkor afs vr 200400]] [[http://sugarbear2.freehostia.com/blog/clive-barkers/ clive barkers undying]] [[http://arqenelk.freehostia.com/library/componenti-informatici/ componenti informatici]] [[http://snmnstrz21.jino-net.ru/small/plasma-hitachi.htm plasma hitachi 32]] [[http://arqenelk.freehostia.com/library/coppie-per2/ coppie per lui toscana]] [[http://darkforest214.jino-net.ru/content/rave-a/ rave a ravenne]] [[http://sugarbear2.freehostia.com/blog/sony-cybershot23/ sony cybershot dsc p73]] [[http://sugarbear2.freehostia.com/blog/villa-di1/ villa di pasquale  sala banchetti]] [[http://my500px.jino-net.ru/topic/www-unicat/ www unicat it]] [[http://arqenelk.freehostia.com/library/vitaminic/ vitaminic]] [[http://darkforest214.jino-net.ru/content/ardis/ ardis]] [[http://darkforest214.jino-net.ru/content/pirna/ pirna]] [[http://nicole-kid1.freehostia.com/offerta-santo/ offerta santo domingo]] [[http://snmnstrz21.jino-net.ru/small/speedy-di.htm speedy di maxicosi]] [[http://arqenelk.freehostia.com/library/fly-pane/ fly pane]] [[http://nicole-kid1.freehostia.com/ac-ac/ ac ac adapter]] [[http://darkforest214.jino-net.ru/content/monitor-computer/ monitor computer 22]] [[http://snmnstrz21.jino-net.ru/small/videoproiettori-usb.htm videoproiettori usb]] [[http://titinthewi.freehostia.com/hp-fax.htm hp fax laser]] [[http://my500px.jino-net.ru/topic/spogliarelliste-immagini/ spogliarelliste immagini]] [[http://sugarbear2.freehostia.com/blog/automodello-a1/ automodello a scoppio]] [[http://helent.freehostia.com/small/ibm-ata.htm ibm ata 100]] [[http://helent.freehostia.com/small/tau.htm tau]] [[http://sugarbear2.freehostia.com/blog/canon-bj/ canon bj i6500]] [[http://darkforest214.jino-net.ru/content/pantaloni-con/ pantaloni con le tasche  linea donna]] [[http://snmnstrz21.jino-net.ru/small/rifkin.htm rifkin]] [[http://nicole-kid1.freehostia.com/testi-bob/ testi bob marley]] [[http://nicole-kid1.freehostia.com/e-family2/ e family bnl it]] [[http://my500px.jino-net.ru/topic/www-arian/ www arian music com]] [[http://nicole-kid1.freehostia.com/cmt-nez/ cmt nez5]] [[http://snmnstrz21.jino-net.ru/small/ministero-pubblica.htm ministero pubblica istruzione]] [[http://snmnstrz21.jino-net.ru/small/antonio-gargiulo.htm antonio gargiulo]] [[http://sugarbear2.freehostia.com/blog/telesystem-decoder1/ telesystem decoder]] [[http://helent.freehostia.com/small/ultrabeat-feelin.htm ultrabeat feelin fine]] [[http://my500px.jino-net.ru/topic/volo-hotel2/ volo hotel rodi]] [[http://nicole-kid1.freehostia.com/driver-epson/ driver epson stylus color 300 xp]] [[http://sugarbear2.freehostia.com/blog/da-sola/ da sola con te]] [[http://my500px.jino-net.ru/topic/voli-last2/ voli last minute malpensa]] [[http://my500px.jino-net.ru/topic/bella-e1/ bella e la bestia]] [[http://darkforest214.jino-net.ru/content/mercedes-ambrus1/ mercedes ambrus fotografie]] [[http://titinthewi.freehostia.com/processori-tualatin.htm processori tualatin]] [[http://arqenelk.freehostia.com/library/summerbanks-com/ summerbanks com]] [[http://darkforest214.jino-net.ru/content/lexmark-z5/ lexmark z 65]] [[http://arqenelk.freehostia.com/library/lo-que2/ lo que ti me das]] [[http://sugarbear2.freehostia.com/blog/body-paintng/ body paintng]] [[http://my500px.jino-net.ru/topic/volo-aereo28/ volo aereo roma toronto]] [[http://nicole-kid1.freehostia.com/Discorso-di1/ discorso di antonio al funerale di cesar]] [[http://helent.freehostia.com/small/cucina-design.htm cucina design]] [[http://helent.freehostia.com/small/madalena.htm madalena]] [[http://snmnstrz21.jino-net.ru/small/francesco-de1.htm francesco de rosa un altra vita]] [[http://titinthewi.freehostia.com/www-scanno.htm www scanno it]] [[http://darkforest214.jino-net.ru/content/inculate-solo/ inculate solo uomini]] [[http://darkforest214.jino-net.ru/content/disposizione/ disposizione]] [[http://helent.freehostia.com/small/copertina-cd22.htm copertina cd moto gp3]] [[http://helent.freehostia.com/small/clinton.htm clinton]] = Parsing Microformats =
= Parsing Microformats =


Microformat parsing mechanisms that depend on documents having even minimal xml properties like well-formedness may fail when consuming non-well-formed content.  [http://tidy.sourceforge.net/ Tidy] or even better [http://people.apache.org/~andyc/neko/doc/html/ CyberNeko] may be a useful work around.
Microformat parsing mechanisms that depend on documents having even minimal xml properties like well-formedness may fail when consuming non-well-formed content.  [http://tidy.sourceforge.net/ Tidy] or even better [http://people.apache.org/~andyc/neko/doc/html/ CyberNeko] may be a useful work around.
Line 7: Line 7:


When parsing class values care must be taken:
When parsing class values care must be taken:
# Class attributes may contain multiple class names, e.g: <code>class="foo vcard bar"</code>
# Class attributes may contain multiple class names separated by whitespace, e.g: <code>class="foo vcard bar"</code>
# Class attributes may contain class names which contain the class name used by a microformat, e.g: <code>class="foo<strong>vcard</strong>bar"</code> <code>class="foo<strong>vcard</strong>"</code>, <code>class="<strong>vcard</strong>bar"</code>.
# Class attributes may contain class names which contain the class name used by a microformat, e.g: <code>class="foo<strong>vcard</strong>bar"</code> <code>class="foo<strong>vcard</strong>"</code>, <code>class="<strong>vcard</strong>bar"</code> - none of which are hCards.
# Multiple class names are seperated by one or more whitespace charchters.  
# Multiple class names can be separated by one <strong>or more</strong> whitespace characters.  
# Class names are case sensitive.
# Class names are case sensitive. microformats class names are always all lowercase (per [[naming-principles]] and [[naming-conventions]]).
   
   
See http://www.w3.org/TR/html401/struct/global.html#h-7.5.2.
See http://www.w3.org/TR/html401/struct/global.html#h-7.5.2.
Line 17: Line 17:
The [http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/ Ultimate getElementsByClassName] JavaScript function may be useful. Then you can do:
The [http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/ Ultimate getElementsByClassName] JavaScript function may be useful. Then you can do:


<code>
<code><pre>
var adrs = document.getElementsByClassName(document, "*", "adr");
var adrs = document.getElementsByClassName(document, "*", "adr");
</code>
</pre></code>


or even:
or even:


<code>
<code><pre>
var cities = document.getElementsByClassName(document, "*", "locality");
var cities = document.getElementsByClassName(document, "*", "locality");
</code>
</pre></code>


=== XSLT example ===
=== XSLT example ===
<code>
<code>
&lt;xsl:if test="contains(
    concat (' ', normalize-space(@class),' '),
    ' <strong>vcard</strong> '
    )" &gt; ...
</code>
JavaScript can also perform XSLT natively in browsers like Firefox. See [[firefox-extensions#XSL_Results|Firefox extensions]] for performing XSL transformations in Firefox without JavaScript.
=== XQuery example ===
Also using XPath...
<pre>&lt;div style="background-color:yellow;">
{
  for $a in doc()//div[@class='vcard']
  let $b := $a/div[@class='fn org' or @class='org fn']
  let $c := $a/div[@class='adr']
  return ($b, $c, &lt;br />)
}
&lt;/div>
</pre>
For example, this could be used against http://technorati.com/about/contact.html. See [[firefox-extensions#XqUSEme|Firefox extensions]] for getting XQuery in Firefox.
Note that the 'class' tests above should really use the more complicated XPath expression used within the XSLT example (in order to allow for other classes to be used on the element, variations in whitespace, etc.), but it is simplified above for demonstration purposes.
Simple XPath expressions can also be used, as these are considered to be valid XQueries.
== Parsing rel/rev values ==
Parsing rel and rev values is similar to parsing class values except for the following differences:
# rel and rev values should be separated by one space.
# rel and rev values are case insensitive.
See http://www.w3.org/TR/html401/types.html#type-links.
== See Also ==
* [[xmdp-brainstorming]]

Latest revision as of 06:46, 16 October 2009

Parsing Microformats

Microformat parsing mechanisms that depend on documents having even minimal xml properties like well-formedness may fail when consuming non-well-formed content. Tidy or even better CyberNeko may be a useful work around. In particular X2V uses XSLT, and tidy to clean any non-well-formed input before processing it.

Parsing class values

When parsing class values care must be taken:

  1. Class attributes may contain multiple class names separated by whitespace, e.g: class="foo vcard bar"
  2. Class attributes may contain class names which contain the class name used by a microformat, e.g: class="foovcardbar" class="foovcard", class="vcardbar" - none of which are hCards.
  3. Multiple class names can be separated by one or more whitespace characters.
  4. Class names are case sensitive. microformats class names are always all lowercase (per naming-principles and naming-conventions).

See http://www.w3.org/TR/html401/struct/global.html#h-7.5.2.

JavaScript example

The Ultimate getElementsByClassName JavaScript function may be useful. Then you can do:

var adrs = document.getElementsByClassName(document, "*", "adr");

or even:

var cities = document.getElementsByClassName(document, "*", "locality");

XSLT example

<xsl:if test="contains(
   concat (' ', normalize-space(@class),' '),
   ' vcard '
   )" > ...

JavaScript can also perform XSLT natively in browsers like Firefox. See Firefox extensions for performing XSL transformations in Firefox without JavaScript.

XQuery example

Also using XPath...

<div style="background-color:yellow;">
{
  for $a in doc()//div[@class='vcard']
  let $b := $a/div[@class='fn org' or @class='org fn']
  let $c := $a/div[@class='adr']
  return ($b, $c, <br />)
}
</div>

For example, this could be used against http://technorati.com/about/contact.html. See Firefox extensions for getting XQuery in Firefox.

Note that the 'class' tests above should really use the more complicated XPath expression used within the XSLT example (in order to allow for other classes to be used on the element, variations in whitespace, etc.), but it is simplified above for demonstration purposes.

Simple XPath expressions can also be used, as these are considered to be valid XQueries.

Parsing rel/rev values

Parsing rel and rev values is similar to parsing class values except for the following differences:

  1. rel and rev values should be separated by one space.
  2. rel and rev values are case insensitive.

See http://www.w3.org/TR/html401/types.html#type-links.

See Also