Fetch JSON from an API

Here should go questions about transforming XML with XSLT and FOP.
Oleksii
Posts: 84
Joined: Wed Jul 19, 2017 6:04 pm
Location: Austria
Contact:

Fetch JSON from an API

Post by Oleksii »

I need to get a JSON file from API like this http://dme-intern.mozarteum.local/digit ... -info/4087
As far it seems that the extension

Code: Select all

dp:url-open
would yield the needed result:
(cf. https://www.ibm.com/docs/en/datapower-g ... dpurl-open)

However, executing of this code

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<stylesheet exclude-result-prefixes="xs xd dme functx dp" version="3.0"
  xmlns:dp="http://www.datapower.com/extensions" extension-element-prefixes="dp"
  xmlns="http://www.w3.org/1999/XSL/Transform" xmlns:dme="http://www.mozarteum.at/ns/dme"
  xmlns:functx="http://www.functx.com" xmlns:map="http://www.w3.org/2005/xpath-functions/map"
  xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" xmlns:xi="http://www.w3.org/2001/XInclude"
  xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xpath-default-namespace="http://www.music-encoding.org/ns/mei">

  <template match="/">
    <result-document href="out.txt">
      <dp:url-open target="http://dme-intern.mozarteum.local/digital-editions/api/work-info/4087"
      > </dp:url-open>
    </result-document>
  </template>

</stylesheet>
triggers a Saxon error "Unknown extension instruction".
I suppose the extension should be declared somewhere. Am I correct? How to do it in oXygen (25.0, build 2023013006)?
P.S. I've searched in the Oxygen documentation for "Saxon extension" and also Saxon documentation like this section:
https://www.saxonica.com/html/documenta ... nsibility/
but did not find what I need.

Regards,
Oleksii
Kind regards,
Oleksii Sapov-Erlinger
xephon
Posts: 140
Joined: Mon Nov 24, 2014 1:49 pm
Location: Greven/Germany

Re: Fetch JSON from an API

Post by xephon »

Hi,
I'm not familiar with this extension. What we do is to download the JSON with curl from Apache Ant first. Then we convert the JSON to XML and then we operate normally on the XML. This is surely the slowest solution, but very easy to maintain.
Best regards
stefan-jung.org – Your DITA/DITA-OT XML consultant
Oleksii
Posts: 84
Joined: Wed Jul 19, 2017 6:04 pm
Location: Austria
Contact:

Re: Fetch JSON from an API

Post by Oleksii »

Thank you for the feedback!
Currently I suppose to go this path: https://stackoverflow.com/a/75661104/7315908
Kind regards,
Oleksii Sapov-Erlinger
Post Reply