onurhb
onurhb

Reputation: 1181

XSLT to DOCX (OOXML) - How to handle hyperlinks

I am trying to convert from XML to DOCX file, however I have a problem with hyperlinks (to external source) as it requires Relationship declaration in the document.xml.rels. Like so:

<Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="http://www.google.com/" TargetMode="External"/>

then I can reference this Relationship by it's id:

<w:hyperlink r:id="rId5">
  <w:r>
    <w:rPr>
      <w:color w:val="#0070BB"/>
      <w:i/>
    </w:rPr>
    <w:t>
      <xsl:value-of select="string(.)"/>
    </w:t>
  </w:r>
</w:hyperlink>

Is it possible to specify the link URL within the hyperlink tag, as an attribute? So I don't have so use another file...

Something like this:

<w:hyperlink external-url="http://...">
  <w:r>
    <w:rPr>
      <w:color w:val="#0070BB"/>
      <w:i/>
    </w:rPr>
    <w:t>
      <xsl:value-of select="string(.)"/>
    </w:t>
  </w:r>
</w:hyperlink>

Upvotes: 0

Views: 231

Answers (1)

wasmachien
wasmachien

Reputation: 1009

If you're not stuck on XSLT 1.0, you could you use <xsl:result-document>. That way you can have multiple outputs from one transformation.

Upvotes: 1

Related Questions