Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

XInclude and XML rendering #26

Open
MarinBernard opened this issue May 2, 2019 · 3 comments
Open

XInclude and XML rendering #26

MarinBernard opened this issue May 2, 2019 · 3 comments

Comments

@MarinBernard
Copy link

Hi,

I'm new to FMPP and I'm trying to have it render a single XML document to a very basic one-liner text file. Templating does work as expected, except regarding the XInclude feature: I can't make FMPP apply the transclusion. In the called template, browsing the DOM with pp.doc returns an xi:include element instead of the target one.

XInclude does work when used with static XML data sources (defined in the main config file), but not with dynamic XML rendering. I use the latest version. What did I forget ?

Config file

recommendedDefaults: 0.9.16
sourceRoot: /home/marin/fmpp/in
outputRoot: /home/marin/fmpp/out
dataRoot:   /home/marin/fmpp/data

modes : [
    ignore(/templates/)
]

data: {
    # Works fine: <xi:include> elements are processed.
    works: xml(music/works/bach/bwv622.xml, {'xincludeAware': true})
}

xmlRenderings: [
    {
        # Does NOT work: <xi:include> elements are returned as-is.
        ifDocumentElementIs: release
        template: templates/release.tags
        xincludeAware: true
        xmlns: {D: http://www.w3.org/1999/xhtml, xi: http://www.w3.org/2001/XInclude}
    }
]

Source XML file

<release xmlns="http://www.w3.org/1999/xhtml"
         xmlns:xi="http://www.w3.org/2001/XInclude">
	<title>My release</title>
	<performances>
		<performance>
			<work>
				<xi:include href="/home/marin/fmpp/data/music/works/bach/bwv622.xml" parse="xml"/>
			</work>
		</performance>
	</performances>
</release>

Template

<#ftl ns_prefixes={"D":"http://www.w3.org/1999/xhtml"}>
<@pp.renameOutputFile extension="txt" />
<#assign release = pp.doc.release>
<#list release.performances.performance.work.* as c>
- ${c?node_name}
</#list>

Output

- include

Instead of the the root element from "/home/marin/fmpp/data/music/works/bach/bwv622.xml".

@ddekany
Copy link
Contributor

ddekany commented May 4, 2019

Indeed, xincludeAware had no effect inside xmlRenderings. I have fixed this in commit adfe51f.

@MarinBernard
Copy link
Author

Hi,

Many thanks for adding this feature. For your information I noticed that xincludeAware was also ineffective when passed as a parameter of pp.loadData. XML data are loaded but XInclude elements are left unprocessed.

Many thanks. I'll try to build 9.1.17 and see what happens.

@ddekany
Copy link
Contributor

ddekany commented May 13, 2019

Are you sure about pp.loadData? Looking at the source code, I don't think it ignores the { 'xincludeAware': true } argument you pass to it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants