@@ -7,20 +7,34 @@ import { XmlParser } from '../../src/dom';
77describe ( 'HTML to LMHT' , ( ) => {
88 const xsltString =
99 `<?xml version="1.0" encoding="UTF-8"?>
10- <xsl:transform
11- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
12- xmlns:xs="http://www.w3.org/2001/XMLSchema"
13- version="2.0"
14- >
10+ <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
1511 <xsl:output method="xml" version="1.0" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" />
1612
17- <xsl:template name="ProcessarTargets">
18- <xsl:param name="Target" />
13+ <!-- Seção de _templates_ utilitários -->
14+ <!-- Os _templates_ abaixo normalmente trabalham com transcrição de valores de atributos LMHT para HTML -->
15+ <xsl:template name="ProcessarInputTypes">
16+ <xsl:param name="InputType" />
1917 <xsl:choose>
20- <xsl:when test="$Target = '_self'">_mesmo</xsl:when>
21- <xsl:when test="$Target = '_blank'">_novo</xsl:when>
22- <xsl:when test="$Target = '_parent'">_pai</xsl:when>
23- <xsl:when test="$Target = '_top'">_topo</xsl:when>
18+ <xsl:when test="$InputType = 'button'">botão</xsl:when>
19+ <xsl:when test="$InputType = 'checkbox'">caixa-checagem</xsl:when>
20+ <xsl:when test="$InputType = 'color'">cor</xsl:when>
21+ <xsl:when test="$InputType = 'date'">data</xsl:when>
22+ <xsl:when test="$InputType = 'email'">e-mail</xsl:when>
23+ <xsl:when test="$InputType = 'file'">arquivo</xsl:when>
24+ <xsl:when test="$InputType = 'hidden'">escondido</xsl:when>
25+ <xsl:when test="$InputType = 'image'">imagem</xsl:when>
26+ <xsl:when test="$InputType = 'month'">mês</xsl:when>
27+ <xsl:when test="$InputType = 'number'">número</xsl:when>
28+ <xsl:when test="$InputType = 'password'">senha</xsl:when>
29+ <xsl:when test="$InputType = 'radio'">rádio</xsl:when>
30+ <xsl:when test="$InputType = 'range'">intervalo</xsl:when>
31+ <xsl:when test="$InputType = 'reset'">reiniciar</xsl:when>
32+ <xsl:when test="$InputType = 'search'">pesquisar</xsl:when>
33+ <xsl:when test="$InputType = 'submit'">enviar</xsl:when>
34+ <xsl:when test="$InputType = 'tel'">telefone</xsl:when>
35+ <xsl:when test="$InputType = 'text'">texto</xsl:when>
36+ <xsl:when test="$InputType = 'time'">hora</xsl:when>
37+ <xsl:when test="$InputType = 'week'">semana</xsl:when>
2438 </xsl:choose>
2539 </xsl:template>
2640 <xsl:template name="ProcessarReferrerPolicy">
@@ -30,9 +44,7 @@ describe('HTML to LMHT', () => {
3044 <xsl:when test="$Policy = 'same-origin'">mesma-origem</xsl:when>
3145 <xsl:when test="$Policy = 'origin'">origem</xsl:when>
3246 <xsl:when test="$Policy = 'origin-when-cross-origin'">origem-quando-origem-cruzada</xsl:when>
33- <xsl:when test="$Policy = 'strict-origin-when-cross-origin'">
34- origem-quando-origem-cruzada-rigorosa
35- </xsl:when>
47+ <xsl:when test="$Policy = 'strict-origin-when-cross-origin'">origem-quando-origem-cruzada-rigorosa</xsl:when>
3648 <xsl:when test="$Policy = 'no-referrer'">sem-referenciador</xsl:when>
3749 <xsl:when test="$Policy = 'no-referrer-when-downgrade'">sem-referenciador-ao-rebaixar</xsl:when>
3850 </xsl:choose>
@@ -64,7 +76,19 @@ describe('HTML to LMHT', () => {
6476 <xsl:when test="$Shape = 'poly'">polígono</xsl:when>
6577 </xsl:choose>
6678 </xsl:template>
79+ <xsl:template name="ProcessarTargets">
80+ <xsl:param name="Target" />
81+ <xsl:choose>
82+ <xsl:when test="$Target = '_self'">_mesmo</xsl:when>
83+ <xsl:when test="$Target = '_blank'">_novo</xsl:when>
84+ <xsl:when test="$Target = '_parent'">_pai</xsl:when>
85+ <xsl:when test="$Target = '_top'">_topo</xsl:when>
86+ </xsl:choose>
87+ </xsl:template>
6788
89+ <!-- Atributos independentes de tags (globais) -->
90+ <!-- Por algum motivo, adicionar id aqui não funciona. -->
91+ <!-- Atributo id, portanto, é usado em todas as estruturas de <corpo>. -->
6892 <xsl:template match="@draggable">
6993 <xsl:attribute name="arrastável">
7094 <xsl:value-of select="." />
@@ -86,7 +110,7 @@ describe('HTML to LMHT', () => {
86110 </xsl:attribute>
87111 </xsl:template>
88112 <xsl:template match="@dir">
89- <xsl:attribute name="@ direção-texto">
113+ <xsl:attribute name="direção-texto">
90114 <xsl:value-of select="." />
91115 </xsl:attribute>
92116 </xsl:template>
@@ -104,9 +128,9 @@ describe('HTML to LMHT', () => {
104128 <xsl:attribute name="idioma">
105129 <xsl:value-of select="." />
106130 </xsl:attribute>
107- </xsl:template>
131+ </xsl:template>
108132 <xsl:template match="@tabindex">
109- <xsl:attribute name="@ índice-tab">
133+ <xsl:attribute name="índice-tab">
110134 <xsl:value-of select="." />
111135 </xsl:attribute>
112136 </xsl:template>
@@ -131,7 +155,8 @@ describe('HTML to LMHT', () => {
131155 <xsl:apply-templates select="node()" />
132156 </lmht>
133157 </xsl:template>
134-
158+
159+ <!-- Especificação de head -->
135160 <xsl:template match="/html/head">
136161 <cabeça>
137162 <xsl:apply-templates select="@*|node()" />
@@ -158,17 +183,18 @@ describe('HTML to LMHT', () => {
158183 <xsl:apply-templates select="node()" />
159184 </base-ligações>
160185 </xsl:template>
186+ <!-- Tag style não é traduzida. -->
161187 <xsl:template match="/html/style">
162- <estilo >
188+ <style >
163189 <xsl:apply-templates select="@*|node()" />
164- </estilo >
190+ </style >
165191 </xsl:template>
166192 <xsl:template match="/html/head/meta">
167193 <meta>
168194 <xsl:for-each select="@*">
169195 <xsl:choose>
170- <xsl:when test="name() = 'name '">
171- <xsl:attribute name="nome ">
196+ <xsl:when test="name() = 'charset '">
197+ <xsl:attribute name="codificação ">
172198 <xsl:value-of select="." />
173199 </xsl:attribute>
174200 </xsl:when>
@@ -177,6 +203,16 @@ describe('HTML to LMHT', () => {
177203 <xsl:value-of select="." />
178204 </xsl:attribute>
179205 </xsl:when>
206+ <xsl:when test="name() = 'http-equiv'">
207+ <xsl:attribute name="diretiva-http">
208+ <xsl:value-of select="." />
209+ </xsl:attribute>
210+ </xsl:when>
211+ <xsl:when test="name() = 'name'">
212+ <xsl:attribute name="nome">
213+ <xsl:value-of select="." />
214+ </xsl:attribute>
215+ </xsl:when>
180216 </xsl:choose>
181217 </xsl:for-each>
182218 <xsl:apply-templates select="node()" />
@@ -207,6 +243,7 @@ describe('HTML to LMHT', () => {
207243 </título>
208244 </xsl:template>
209245
246+ <!-- Especificação de body -->
210247 <xsl:template match="/html/body">
211248 <corpo>
212249 <xsl:apply-templates select="@*|node()" />
@@ -237,7 +274,7 @@ describe('HTML to LMHT', () => {
237274 </aparte>
238275 </xsl:template>
239276 <xsl:template match="/html/body//area">
240- <area >
277+ <área >
241278 <xsl:for-each select="@*">
242279 <xsl:choose>
243280 <xsl:when test="name() = 'target'">
@@ -292,7 +329,7 @@ describe('HTML to LMHT', () => {
292329 </xsl:choose>
293330 </xsl:for-each>
294331 <xsl:apply-templates select="node()" />
295- </area >
332+ </área >
296333 </xsl:template>
297334 <xsl:template match="/html/body//textarea">
298335 <área-texto>
@@ -393,7 +430,7 @@ describe('HTML to LMHT', () => {
393430 </aspas>
394431 </xsl:template>
395432 <xsl:template match="/html/body//audio">
396- <audio >
433+ <áudio >
397434 <xsl:for-each select="@*">
398435 <xsl:choose>
399436 <xsl:when test="name() = 'controls'">
@@ -439,7 +476,7 @@ describe('HTML to LMHT', () => {
439476 </xsl:choose>
440477 </xsl:for-each>
441478 <xsl:apply-templates select="node()" />
442- </audio >
479+ </áudio >
443480 </xsl:template>
444481 <xsl:template match="/html/body//button">
445482 <botão>
@@ -640,6 +677,11 @@ describe('HTML to LMHT', () => {
640677 <xsl:apply-templates select="@*|node()" />
641678 </envelope-texto>
642679 </xsl:template>
680+ <xsl:template match="/html/body//slot">
681+ <escatel>
682+ <xsl:apply-templates select="@*|node()" />
683+ </escatel>
684+ </xsl:template>
643685 <xsl:template match="/html/body//label">
644686 <etiqueta>
645687 <xsl:for-each select="@*">
@@ -704,6 +746,7 @@ describe('HTML to LMHT', () => {
704746 </descrição>
705747 </xsl:template>
706748
749+ <!-- Formulários -->
707750 <xsl:template match="/html/body//form">
708751 <formulário>
709752 <xsl:for-each select="@*">
@@ -838,11 +881,13 @@ describe('HTML to LMHT', () => {
838881 </xsl:when>
839882 <xsl:when test="name() = 'type'">
840883 <xsl:attribute name="tipo">
841- <xsl:value-of select="." />
884+ <xsl:call-template name="ProcessarInputTypes">
885+ <xsl:with-param name="InputType" select="." />
886+ </xsl:call-template>
842887 </xsl:attribute>
843888 </xsl:when>
844- <xsl:when test="name() = 'valor '">
845- <xsl:attribute name="value ">
889+ <xsl:when test="name() = 'value '">
890+ <xsl:attribute name="valor ">
846891 <xsl:value-of select="." />
847892 </xsl:attribute>
848893 </xsl:when>
@@ -851,12 +896,17 @@ describe('HTML to LMHT', () => {
851896 <xsl:apply-templates select="node()" />
852897 </campo>
853898 </xsl:template>
854-
855899 <xsl:template match="/html/body//form/legend">
856900 <título>
857901 <xsl:apply-templates select="@*|node()" />
858902 </título>
859903 </xsl:template>
904+
905+ <xsl:template match="/html/body//hgroup">
906+ <grupo-títulos>
907+ <xsl:apply-templates select="@*|node()" />
908+ </grupo-títulos>
909+ </xsl:template>
860910 <xsl:template match="/html/body//img">
861911 <imagem>
862912 <xsl:for-each select="@*">
@@ -975,6 +1025,7 @@ describe('HTML to LMHT', () => {
9751025 <linha-horizontal />
9761026 </xsl:template>
9771027
1028+ <!-- Listas -->
9781029 <xsl:template match="/html/body//dl">
9791030 <lista-definições>
9801031 <xsl:apply-templates select="@*|node()" />
@@ -1174,11 +1225,21 @@ describe('HTML to LMHT', () => {
11741225 <xsl:apply-templates select="node()" />
11751226 </recurso>
11761227 </xsl:template>
1228+ <xsl:template match="/html/body//output">
1229+ <resultado>
1230+ <xsl:apply-templates select="@*|node()" />
1231+ </resultado>
1232+ </xsl:template>
11771233 <xsl:template match="/html/body//s">
11781234 <riscado>
11791235 <xsl:apply-templates select="@*|node()" />
11801236 </riscado>
11811237 </xsl:template>
1238+ <xsl:template match="/html/body//footer">
1239+ <rodapé>
1240+ <xsl:apply-templates select="@*|node()" />
1241+ </rodapé>
1242+ </xsl:template>
11821243 <xsl:template match="/html/body//script">
11831244 <script>
11841245 <xsl:apply-templates select="@*|node()" />
@@ -1190,6 +1251,7 @@ describe('HTML to LMHT', () => {
11901251 </seção>
11911252 </xsl:template>
11921253
1254+ <!-- Seleção -->
11931255 <xsl:template match="/html/body//select">
11941256 <seleção>
11951257 <xsl:apply-templates select="@*|node()" />
@@ -1298,6 +1360,7 @@ describe('HTML to LMHT', () => {
12981360 </subscrito>
12991361 </xsl:template>
13001362
1363+ <!-- Tabelas -->
13011364 <xsl:template match="/html/body//table">
13021365 <tabela>
13031366 <xsl:apply-templates select="@*|node()" />
@@ -1422,6 +1485,7 @@ describe('HTML to LMHT', () => {
14221485 </texto-pequeno>
14231486 </xsl:template>
14241487
1488+ <!-- Títulos -->
14251489 <xsl:template match="/html/body//h1">
14261490 <título1>
14271491 <xsl:apply-templates select="@*|node()" />
@@ -1452,7 +1516,8 @@ describe('HTML to LMHT', () => {
14521516 <xsl:apply-templates select="@*|node()" />
14531517 </título6>
14541518 </xsl:template>
1455- </xsl:transform>` ;
1519+ </xsl:transform>
1520+ ` ;
14561521
14571522 it ( 'Trivial' , async ( ) => {
14581523 const xmlString =
0 commit comments