Function unparsed-text() reads an external resource and returns its contents as a string. Please note the difference in the example between unparsed-text() and document() functions.
Errors caused by the function unparsed-text() are not recoverable. Function unparsed-text-available() can be used to make sure that an error will not occur.
|
XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/> <xsl:template match="/aaa"> <available> <xsl:value-of select="unparsed-text-available('ext4.xml','utf-8')"/> </available> <xxx> <xsl:copy-of select="unparsed-text('ext4.xml','utf-8')"/> </xxx> <xxx> <xsl:copy-of select="document('ext4.xml')"/> </xxx> </xsl:template> </xsl:stylesheet> |
|
|
XML
<aaa/> ext4.xml
<bbb> & - & </bbb> |
Output
<available>true</available> <xxx> <bbb> & - & </bbb> </xxx> <xxx> <bbb> & - & </bbb> </xxx> |
| Previous chapter: | Groups |
| Next chapter: | Multiple stylesheets |
| Previous page: | Reading external document using doc function |
| Next page: | - - - |