XSLT copy from external document











up vote
0
down vote

favorite












In XSLT 2.0 I am transforming a tei-xml document into HTML. In that transformationI need content from another document: I want to copy/transform a small set of nodes from the second document into the HTML output.



While processing the principal tei document I get the id and assign it to a variable:



<xsl:variable name="licenseid" select="./replace(@corresp,'#','')"/>


Then I go out to the other document and fetch the node using the variable, with the returned node assigned to a variable:



<xsl:variable name="licenseloc" select="doc(concat($somepath,'includes_sourcedesc.xml'))//tei:list[@type='copyright_type']/tei:item[@xml:id=$licenseid]"/>


This node I obtain looks like this:



<list type="copyright_type">
<item xml:id="copyright-cc-by-nc-sa-4.0">
<desc xml:lang="en">This work is made by available the author under the
<ref target="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike
4.0 International License</ref>.</desc>
</item>
</list>


And I want to transform it (from desc) to this:



<span>This work is made by available by the author under the 
<a href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike
4.0 International License</a>.</span>


If this were in my 'current' tei document I would handle it through templates, but I'm unsure how to copy and transform the nested layers from within a different 'current' document.










share|improve this question




















  • 2




    You can use <xsl:apply-templates select="$licenseloc"/> (if needed with a mode="some-mode") and then write templates as usual for the element(s).
    – Martin Honnen
    Nov 9 at 22:25










  • @MartinHonnen well now that you say it, it's obvious. I was locked into the idea that templates must concern the 'current file' instead of thinking with 'nodes'. Thanks very much.
    – jbrehr
    Nov 10 at 9:56















up vote
0
down vote

favorite












In XSLT 2.0 I am transforming a tei-xml document into HTML. In that transformationI need content from another document: I want to copy/transform a small set of nodes from the second document into the HTML output.



While processing the principal tei document I get the id and assign it to a variable:



<xsl:variable name="licenseid" select="./replace(@corresp,'#','')"/>


Then I go out to the other document and fetch the node using the variable, with the returned node assigned to a variable:



<xsl:variable name="licenseloc" select="doc(concat($somepath,'includes_sourcedesc.xml'))//tei:list[@type='copyright_type']/tei:item[@xml:id=$licenseid]"/>


This node I obtain looks like this:



<list type="copyright_type">
<item xml:id="copyright-cc-by-nc-sa-4.0">
<desc xml:lang="en">This work is made by available the author under the
<ref target="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike
4.0 International License</ref>.</desc>
</item>
</list>


And I want to transform it (from desc) to this:



<span>This work is made by available by the author under the 
<a href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike
4.0 International License</a>.</span>


If this were in my 'current' tei document I would handle it through templates, but I'm unsure how to copy and transform the nested layers from within a different 'current' document.










share|improve this question




















  • 2




    You can use <xsl:apply-templates select="$licenseloc"/> (if needed with a mode="some-mode") and then write templates as usual for the element(s).
    – Martin Honnen
    Nov 9 at 22:25










  • @MartinHonnen well now that you say it, it's obvious. I was locked into the idea that templates must concern the 'current file' instead of thinking with 'nodes'. Thanks very much.
    – jbrehr
    Nov 10 at 9:56













up vote
0
down vote

favorite









up vote
0
down vote

favorite











In XSLT 2.0 I am transforming a tei-xml document into HTML. In that transformationI need content from another document: I want to copy/transform a small set of nodes from the second document into the HTML output.



While processing the principal tei document I get the id and assign it to a variable:



<xsl:variable name="licenseid" select="./replace(@corresp,'#','')"/>


Then I go out to the other document and fetch the node using the variable, with the returned node assigned to a variable:



<xsl:variable name="licenseloc" select="doc(concat($somepath,'includes_sourcedesc.xml'))//tei:list[@type='copyright_type']/tei:item[@xml:id=$licenseid]"/>


This node I obtain looks like this:



<list type="copyright_type">
<item xml:id="copyright-cc-by-nc-sa-4.0">
<desc xml:lang="en">This work is made by available the author under the
<ref target="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike
4.0 International License</ref>.</desc>
</item>
</list>


And I want to transform it (from desc) to this:



<span>This work is made by available by the author under the 
<a href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike
4.0 International License</a>.</span>


If this were in my 'current' tei document I would handle it through templates, but I'm unsure how to copy and transform the nested layers from within a different 'current' document.










share|improve this question















In XSLT 2.0 I am transforming a tei-xml document into HTML. In that transformationI need content from another document: I want to copy/transform a small set of nodes from the second document into the HTML output.



While processing the principal tei document I get the id and assign it to a variable:



<xsl:variable name="licenseid" select="./replace(@corresp,'#','')"/>


Then I go out to the other document and fetch the node using the variable, with the returned node assigned to a variable:



<xsl:variable name="licenseloc" select="doc(concat($somepath,'includes_sourcedesc.xml'))//tei:list[@type='copyright_type']/tei:item[@xml:id=$licenseid]"/>


This node I obtain looks like this:



<list type="copyright_type">
<item xml:id="copyright-cc-by-nc-sa-4.0">
<desc xml:lang="en">This work is made by available the author under the
<ref target="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike
4.0 International License</ref>.</desc>
</item>
</list>


And I want to transform it (from desc) to this:



<span>This work is made by available by the author under the 
<a href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike
4.0 International License</a>.</span>


If this were in my 'current' tei document I would handle it through templates, but I'm unsure how to copy and transform the nested layers from within a different 'current' document.







xslt xslt-2.0






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 21:42

























asked Nov 9 at 21:24









jbrehr

110112




110112








  • 2




    You can use <xsl:apply-templates select="$licenseloc"/> (if needed with a mode="some-mode") and then write templates as usual for the element(s).
    – Martin Honnen
    Nov 9 at 22:25










  • @MartinHonnen well now that you say it, it's obvious. I was locked into the idea that templates must concern the 'current file' instead of thinking with 'nodes'. Thanks very much.
    – jbrehr
    Nov 10 at 9:56














  • 2




    You can use <xsl:apply-templates select="$licenseloc"/> (if needed with a mode="some-mode") and then write templates as usual for the element(s).
    – Martin Honnen
    Nov 9 at 22:25










  • @MartinHonnen well now that you say it, it's obvious. I was locked into the idea that templates must concern the 'current file' instead of thinking with 'nodes'. Thanks very much.
    – jbrehr
    Nov 10 at 9:56








2




2




You can use <xsl:apply-templates select="$licenseloc"/> (if needed with a mode="some-mode") and then write templates as usual for the element(s).
– Martin Honnen
Nov 9 at 22:25




You can use <xsl:apply-templates select="$licenseloc"/> (if needed with a mode="some-mode") and then write templates as usual for the element(s).
– Martin Honnen
Nov 9 at 22:25












@MartinHonnen well now that you say it, it's obvious. I was locked into the idea that templates must concern the 'current file' instead of thinking with 'nodes'. Thanks very much.
– jbrehr
Nov 10 at 9:56




@MartinHonnen well now that you say it, it's obvious. I was locked into the idea that templates must concern the 'current file' instead of thinking with 'nodes'. Thanks very much.
– jbrehr
Nov 10 at 9:56

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233450%2fxslt-copy-from-external-document%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233450%2fxslt-copy-from-external-document%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Schultheiß

Verwaltungsgliederung Dänemarks

Liste der Kulturdenkmale in Wilsdruff