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.
xslt xslt-2.0
add a comment |
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.
xslt xslt-2.0
2
You can use<xsl:apply-templates select="$licenseloc"/>
(if needed with amode="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
add a comment |
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.
xslt xslt-2.0
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
xslt xslt-2.0
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 amode="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
add a comment |
2
You can use<xsl:apply-templates select="$licenseloc"/>
(if needed with amode="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
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
2
You can use
<xsl:apply-templates select="$licenseloc"/>
(if needed with amode="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