of 25 /25
XSLT e recursividade estrutural Helena Galhardas DEI IST

XSLT e recursividade estrutural Helena Galhardas DEI IST

Embed Size (px)

Text of XSLT e recursividade estrutural Helena Galhardas DEI IST

  • Slide 1
  • XSLT e recursividade estrutural Helena Galhardas DEI IST
  • Slide 2
  • Agenda Recursividade estrutural XSLT
  • Slide 3
  • Recursividade estrutural: um paradigma diferente Dados so vistos como conjuntos e um operador de unio: {a:3, a:{b:one, c:5}, b:4} = {a:3} U {a:{b:one,c:5}} U {b:4}
  • Slide 18
  • XSLT vs recursividade estrutural XSLT: Sobre rvores Pode entrar em ciclo infinito Recursividade estrutural: Grafos arbitrrios Termina sempre
  • Slide 19
  • Programa XSLT simples Copia a entrada:
  • Slide 20
  • Resoluo de conflitos para regras de template Se vrias regras de template fazem match, escolher a que tem maior prioridade Prioridades podem ser: Explicitas: implicitas: regras ad-hoc dadas pelo W3, baseadas no match match=abc prioridade 0. match=[... some namespace name... ] prioridade -0.25. match=node() prioridade -0.5.
  • Slide 21
  • Modos em XSLT Modo = nome para um grupo de template rules til quando o mesmo n tem que ser percorrido vrias vezes Equivalente a ter mltiplas funes recursivas
  • Slide 22
  • Exemplo f(T1 U T2) = f(T1) U f(T2) f({a: T}) = {result:T} U g(T) f({}) = {} f(V) = V g(T1 U T2) = g(T1) U g(T2) g({b: T}) = f(T) g({}) = {} g(V) = V f(T1 U T2) = f(T1) U f(T2) f({a: T}) = {result:T} U g(T) f({}) = {} f(V) = V g(T1 U T2) = g(T1) U g(T2) g({b: T}) = f(T) g({}) = {} g(V) = V Calcular o caminho (a.b)* :
  • Slide 23
  • Exerccio Escreva um programa XSLT que transforme o doc XML: Noutro com o formato: XML Peter Wood Algorithms Trevor Fenner Assuma que teaches o elemento raz e que os atributos course e lecturer so obrigatrios. O programa deve executar-se para qualquer nmero de ocorrncias do elemento teaches-tuple.
  • Slide 24
  • Tpicos prximas aulas (Prof. Pvel Calado) Extraco de dados da Web Extraco de informao
  • Slide 25
  • Referncias S. Abiteboul, P. Buneman, D. Suciu, Data on the Web, From Relations to Semistructured Data and XML, Morgan Kaufmann, 2000, (caps 5 e 6) Peter Wood, Slides on Representing and Querying Data on the Web, http://www.dcs.bbk.ac.uk/~ptw/teaching/data-on-the- web.html. Dan Suciu, Slides on The semistructured data model, CSE 590ds: Management of XML and Semistructured Data, http://www.cs.washington.edu/education/courses/cse590ds/01sp/ http://www.cs.washington.edu/education/courses/cse590ds/01sp/ www.w3.org/Style/XSL/ W3C's XSL home page www.w3.org/Style/XSL/ hands-on-xsl.pdf hands-on XSL: a simple exercise demonstrating the principles of XSLT (previously available from IBM developerWorks) hands-on-xsl.pdfIBM developerWorks nwalsh.com/docs/tutorials/xsl/ an XSL tutorial by Paul Grosso and Norman Walsh nwalsh.com/docs/tutorials/xsl/ www.zvon.org/xxl/XSLTreference/Output/ an XSLT reference using examples; links to other XML tutorials www.zvon.org/xxl/XSLTreference/Output/ metalab.unc.edu/xml/books/bible/updates/14.html a chapter from the XML Bible on XSL Transformations (and XPath) metalab.unc.edu/xml/books/bible/updates/14.html