Open sashafirsov opened 1 year ago
the content from remote server can be used as is in case the content is a pure XSLT. In this case all dependencies are resolved by XSLT engine. *
A relative path for
xsl:include/@href
orxsl:import/@href
is resolved against the directory of the XSLT file that does the including or importing.
For HTML it has to be converted into XSLT first ( as inline DCE template ) with path resolution relative to imported file URL.
The path resolution has to be importmaps aware.
if (HTMLScriptElement.supports('importmap')) {
// The importmap feature is supported.
}
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap
The standard does not support locally scoped maps. But in DCE if the imported HTML module has it, the context root(DCE) would be able to resolve URLs accounting as global as local import maps.
Same as embedded template case. Just instead of declaration payload, the template is taken by ID.
xsltString
getter exposes assembled from XSLT document template to be used in constructor and by utility API in dev tools. The getter pattern delays the actual load and CPU consumption to the moment when DCE instance created.XSLTProcessor
cached in DCE declaration and exposed as getterDCE instance
instance.xml
transform()
performs initial UI stateapplySlices()
initializes the business logic leading to series of transforms applySlices()
cycle ^^when src
is presented and points to external document:
transform()
and applySlices()
sequence to initialize new template cycleThe inline template would be used to render the DCE instance before the remote template loaded and XSLTProcessor
created.
Once the error happen during the load or creating the XSLTProcessor
, the template
data slice would be adjusted with the error and all DCE instances would receive the template change notification which would lead to trigger the transformation cycle.
If the inline template has the template.error
handling, it would render the matching UI or ignore the error completely leaving the fallback UI.
DCE out of the box would display the template-error
slot with debug info warning which would include the URL and potential error cause. The content can be overridden by providing custom template-error
slot either on DCE declaration or on DCE instance level (samples TBD). The error suppressing can be done on DCE declaration payload level which would account the template/error
data slice.
connectedCallback()
checks src
attribute. When not defined, templateRootS is getTemplateChildren(this, this.children)
#localHash
, templateRootS is getTemplateChildren( $( getContextRoot(this), localHash) )
with context root tried recursively up to document leveldom = await xhrTemplate(src)
cache[ src ] = dom
$( dom, urlhash ).map( resolveTemplateNode )
getTemplateChildren( dom, [dom] )
Once templateRootS
available, there are 3 choices:
attributes
section.attributes
section. 🤔 External template content. Take the whole, root element or children?
html
root is not injectable, but is it toxic?
Use cases:
<custom-element tag="dce-internal" src="#template1">
- reference the template in page DOM<custom-element src="#template2"></custom-element>
- inline instantiation, no tag<custom-element tag="dce-external" src="toc.html">
- external file<custom-element tag="dce-hash" src="../index.html#shared-template">
- html template by ID in external file<custom-element tag="dce-hash" src="../index.html#svg1" >
- html with SVG collection<custom-element tag="dce-hash" src="../index.xhtml#xsl1" >
- xhtml/xml with embedded templates lib<custom-element tag="dce-hash" src="embed-1.html" >
- external file with embedding of another external DCE