ComLock
November 6, 2015, 11:35am
1
Enonic version: 4.7.11
OS: Linux
The Datasource API has getUrlAsXml
https://enonic.com/docs/4.7/util-data-sources.html#Utildatasources-getUrlAsXml
Is there something like that for xsl ?
bhj
November 6, 2015, 11:48am
2
There is the XSLT document() function
<xsl:copy-of select="document('URL_OF_XML')/>
…but its use cases are very limited in the context of rendering a page in Enonic. I’ve only seen it been used as a way to load an XML config file from the local file structure, for instance the way Enonic STK retreives site config variables from line 27 in stk-variables.xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet exclude-result-prefixes="#all" version="2.0" xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:stk="http://www.enonic.com/cms/xslt/stk">
<xsl:import href="system.xsl"/>
<!-- ########## Context variables ########## -->
<xsl:variable name="stk:result" as="element()" select="/result"/>
<xsl:variable name="stk:current-resource" as="element()" select="/result/context/resource"/>
<xsl:variable name="stk:site-name" as="xs:string" select="/result/context/site/name"/>
<xsl:variable name="stk:rendered-page" as="element()?" select="/result/context/page"/>
<xsl:variable name="stk:path" as="xs:string" select="concat('/', string-join(($stk:current-resource/path/resource/name, $stk:current-resource[@key != $stk:current-resource/path/resource[position() = last()]/@key]/name), '/'))"/>
<xsl:variable name="stk:language" as="xs:string" select="if (normalize-space(/result/context/locale)) then /result/context/locale else /result/context/@languagecode"/>
<xsl:variable name="stk:device-class" as="xs:string" select="if (/result/context/device-class) then /result/context/device-class else 'not-set'"/>
<xsl:variable name="stk:user" as="element()?" select="/result/context/user"/>
This file has been truncated. show original
What is it that you want to accomplish?
ComLock
November 6, 2015, 11:52am
3
bhj
November 6, 2015, 11:52am
4
Take a look at how it’s done in Enonic STK. That’s much more relevant for the scope that’s possible in Enonic CMS.