Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown conversion for pt-BR - Replace - XSLT section ⚠️ Do not squash ⚠️ #8531

Merged
merged 2 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions files/pt-br/web/xslt/index.html

This file was deleted.

37 changes: 37 additions & 0 deletions files/pt-br/web/xslt/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: XSLT
slug: Web/XSLT
tags:
- NeedsTranslation
- TopicStub
- XSLT
translation_of: Web/XSLT
---
{{XSLTRef}}

**Extensible Stylesheet Language Transformations (XSLT)** is an [XML](/pt-BR/docs/Web/XML/XML_introduction)-based language used, in conjunction with specialized processing software, for the transformation of XML documents.

Although the process is referred to as "transformation," the original document is not changed; rather, a new XML document is created based on the content of an existing document. Then, the new document may be serialized (output) by the processor in standard XML syntax or in another format, such as [HTML](/pt-BR/docs/Web/HTML) or plain text.

XSLT is most often used to convert data between different XML schemas or to convert XML data into web pages or PDF documents.

## Documentation

- [XSLT Element Reference](/pt-BR/docs/Web/XSLT/Element)
- : Reference.
- [Transforming XML with XSLT](/pt-BR/docs/Web/XSLT/Transforming_XML_with_XSLT)
- : XSLT allows a stylesheet author to transform a primary XML document in two significant ways: manipulating and sorting the content, including a wholesale reordering of it if so desired, and transforming the content into a different format.
- [Using the Mozilla JavaScript interface to XSL Transformations](/pt-BR/docs/Web/XSLT/Using_the_Mozilla_JavaScript_interface_to_XSL_Transformations)
- : This document describes the JavaScript interface to the XSLT processing engine in Mozilla 1.2 and up.
- [Specifying parameters using processing instructions](/pt-BR/docs/Web/XSLT/PI_Parameters)
- : Firefox allows stylesheet parameters to be specified when using the `<?xml-stylesheet?>` processing instruction. This is done using the `<?xslt-param?>` PI described in this document.
- [XSLT Tutorial](https://www.w3schools.com/xml/xsl_intro.asp)
- : This [W3Schools](https://www.w3schools.com) tutorial teaches the reader how to use XSLT to transform XML documents into other formats, like XHTML.
- [What is XSLT?](https://www.xml.com/pub/a/2000/08/holman/)
- : This extensive introduction to XSLT and XPath assumes no prior knowledge of the technologies and guides the reader through background, context, structure, concepts and introductory terminology.
- [Common XSLT Errors](/pt-BR/docs/Web/XSLT/Common_errors)
- : This article lists some common problems using XSLT in Firefox.

## Related Topics

- [XML](/pt-BR/docs/Web/XML/XML_introduction), [XPath](/pt-BR/docs/Web/XPath)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
title: Exemplo Avançado
slug: Web/XSLT/XSLT_JS_interface_in_Gecko/Advanced_Example
translation_of: Web/XSLT/XSLT_JS_interface_in_Gecko/Advanced_Example
original_slug: The_XSLT_JavaScript_Interface_in_Gecko/Advanced_Example
---
## Exemplo Avançado

O exemplo avançado apresentará vários tipos de divs baseado em seu conteúdo. O exemplo permite tipificar o conteúdo muitas vezes, alternando entre tipos ascendente ou descendente. O JavaScript apenas carrega o arquivo .xsl a primeira vez, e prepara a variável `xslloaded` verdadeira (true) assim que o arquivo tiver terminado de carregar. Usando o método `getParameter` no obejto `XSLTProcessor`, o código pode decidir pelo tipo ascendente ou descendente. Se o parâmetro estiver vazio o padrão é ascendente (primeira vezes que o tipo aparece, como não há valor para isto no aarquivo XSLT). O valor do tipo é colocado usando `setParameter`.

The XSLT file has a parameter called `myOrder` that JavaScript sets to change the sorting method. The `xsl:sort` element's order attribute can access the value of the parameter using `$myOrder`. However, the value needs to be an XPATH expression and not a string, so `{$myOrder}` is used. Using {} evaluates the content as an XPath expression.

Once the transformation is complete, the result is appened to the document, as shown in this example.

**Figure 7 : Sorting based on div contentview example**

```js
// XHTML Fragment:

<div id="example">
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
</div>

// JavaScript

var xslRef;
var xslloaded = false;
var xsltProcessor = new XSLTProcessor();
var myDOM;

var xmlRef = document.implementation.createDocument("", "", null);

function sort() {
if (!xslloaded){
p = new XMLHttpRequest();
p.open("GET", "example2.xsl", false);
p.send(null);

xslRef = p.responseXML;
xsltProcessor.importStylesheet(xslRef);
xslloaded = true;
}

// create a new XML document in memory
xmlRef = document.implementation.createDocument("", "", null);

// we want to move a part of the DOM from an HTML document to an XML document.
// importNode is used to clone the nodes we want to process via XSLT - true makes it do a deep clone
var myNode = document.getElementById("example");
var clonedNode = xmlRef.importNode(myNode, true);

// after cloning, we append
xmlRef.appendChild(clonedNode);

// set the sorting parameter in the XSL file
var sortVal = xsltProcessor.getParameter(null, "myOrder");

if (sortVal == "" || sortVal == "descending")
xsltProcessor.setParameter(null, "myOrder", "ascending");
else
xsltProcessor.setParameter(null, "myOrder", "descending");

// initiate the transformation
var fragment = xsltProcessor.transformToFragment(xmlRef, document);

// clear the contents
document.getElementById("example").innerHTML = "";

myDOM = fragment;
// add the new content from the transformation
document.getElementById("example").appendChild(fragment)
}

// XSL Stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" />

<xsl:param name="myOrder" />

<xsl:template match="/">

<xsl:apply-templates select="/div//div">
<xsl:sort select="." data-type="number" order="{$myOrder}" />
</xsl:apply-templates>
</xsl:template>

<xsl:template match="div">
<xsl:copy-of select="." />
</xsl:template>
</xsl:stylesheet>
```
25 changes: 0 additions & 25 deletions files/pt-br/web/xslt/xslt_js_interface_in_gecko/index.html

This file was deleted.

22 changes: 22 additions & 0 deletions files/pt-br/web/xslt/xslt_js_interface_in_gecko/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: The XSLT/JavaScript Interface in Gecko
slug: Web/XSLT/XSLT_JS_interface_in_Gecko
tags:
- DOM
- NeedsTranslation
- TopicStub
- XSLT
translation_of: Web/XSLT/XSLT_JS_interface_in_Gecko
original_slug: The_XSLT_JavaScript_Interface_in_Gecko
---
1. [Introduction](/pt-BR/docs/The_XSLT//JavaScript_Interface_in_Gecko/Introduction "en/The_XSLT//JavaScript_Interface_in_Gecko/Introduction")
2. [JavaScript/XSLT Bindings](/pt-BR/docs/The_XSLT//JavaScript_Interface_in_Gecko/JavaScript//XSLT_Bindings "en/The_XSLT//JavaScript_Interface_in_Gecko/JavaScript//XSLT_Bindings")
3. [Basic Example](/pt-BR/docs/The_XSLT//JavaScript_Interface_in_Gecko/Basic_Example "en/The_XSLT//JavaScript_Interface_in_Gecko/Basic_Example")
4. [Setting Parameters](/pt-BR/docs/The_XSLT//JavaScript_Interface_in_Gecko/Setting_Parameters "en/The_XSLT//JavaScript_Interface_in_Gecko/Setting_Parameters")
5. [Advanced Example](/pt-BR/docs/The_XSLT//JavaScript_Interface_in_Gecko/Advanced_Example "en/The_XSLT//JavaScript_Interface_in_Gecko/Advanced_Example")
6. [Interface List](/pt-BR/docs/The_XSLT//JavaScript_Interface_in_Gecko/Interface_List "en/The_XSLT//JavaScript_Interface_in_Gecko/Interface_List")
7. [Resources](/pt-BR/docs/The_XSLT//JavaScript_Interface_in_Gecko/Resources "en/The_XSLT//JavaScript_Interface_in_Gecko/Resources")

## See also

- [Using the Mozilla JavaScript interface to XSL Transformations](/pt-BR/docs/Using_the_Mozilla_JavaScript_interface_to_XSL_Transformations)