Search code examples
xmlxsltxpathxslt-1.0dita

xslt how to get value from an xml present as a link(href) in source xml


I have the below code in source file

    <?xml version="1.0" encoding="utf-8"?>
    <?dx form=DxMapR4?>
    <!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "Map.dtd"[]>
    <map id="DocID027853" rev="1" title="AN4696" ditaarch:DITAArchVersion="1.2"
      domains="(topic delay-d)                          (map mapgroup-d)                           (topic indexing-d)                          (map glossref-d)                          (topic hi-d)                           (topic ut-d)                           (topic hazard-d)                          (topic abbrev-d)                          (topic pr-d)                           (topic sw-d)                          (topic ui-d)                         "
      class="- map/map " xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/">
      <data name="DocType" value="Application note" class="- topic/data "/>
      <data name="AuthorName" value="Laura Vanzago" class="- topic/data "/>
      <topicref type="reference" locktitle="yes" navtitle="@NA" toc="no" class="- map/topicref "
        href="DocID027853_AN4696_short_description.dita"/>
topicref navtitle="SPWF01Sx power-up" class="- map/topicref "
    href="DocID027853_AN4696_6_SPWF01Sxxx_power_up.dita"/>
  <topicref navtitle="Glossary" class="- map/topicref " href="DocID027853_AN4696_7_Glossary.dita"/>
  <topicref navtitle="References" class="- map/topicref "
    href="DocID027853_AN4696_8_References.dita"/>
    <map/>

Now I want to parse the xml file present in first topicrefi.e."DocID027853_AN4696_short_description.dita".

Inside this file there is a title tag whose value I want to copy in my initial source xml. How can I do that? Is it possible using xslt to parse this other xml and copy its data in my source xml?


Solution

  • You can use the document() function followed by the Xpath of the element you want to select, e.g. <xsl:value-of select="document(DocID027853_AN4696_short_description.dita)/thetag"/>.