xsl:result-document : Invalid URI syntax: URI is not absolute

Post here questions and problems related to editing and publishing DITA content.
msambasiva
Posts: 87
Joined: Tue Jul 17, 2018 6:57 am

xsl:result-document : Invalid URI syntax: URI is not absolute

Post by msambasiva »

Hi All,

DITA-OT 2.4.6

Below is the template to create a ditamap for each chapter in conversion of xml to generic dita. It's working fine in my local laptop. When I deploy the code to our linux server, and run the conversion process, it's failing with below error message.


Running:
/uae/java/current/bin/java \
'TransformUsingXMLSchema' \
'/h/uaework/staging/docs/03/s20062603/en/Recruiting_Cloud.xml' \
'/h/uaework/custom/doctypes/CommonDita/xsl/fusion2dita.xsl' \
'/h/uaework/staging/docs/03/s20062603/en/Recruiting_Cloud/Recruiting_Cloud.ditamap' |
On Sun Aug 23 23:13:42 2020

JAVA: Adding bookmap...
JAVA: Error at xsl:result-document on line 214 of fusion2fusionMap.xsl:
JAVA: Exception thrown by OutputURIResolver: Invalid URI syntax: URI is not absolute
JAVA: at xsl:apply-templates (file:/h/uaework/custom/doctypes/CommonDita/xsl/fusion2fusionMap.xsl#43)
JAVA: processing /fusionMap/chapter[1]
JAVA: at xsl:apply-templates (file:///h/uaework/custom/doctypes/CommonDita/xsl/fusion2dita.xsl#161)
JAVA: processing /fusionMap
JAVA: Error converting from '/h/uaework/staging/docs/03/s20062603/en/Recruiting_CloudUsing_Hiring_20062603c.xml' to '/h/uaework/staging/docs/03/s20062603/en/Recruiting_CloudUsing_Hiring_20062603dm/Recruiting_CloudUsing_Hiring_20062603c.ditamap' using '/h/uaework/custom/doctypes/CommonDita/xsl/fusion2dita.xsl'
JAVA:
JAVA: ; SystemID: file:/h/uaework/custom/doctypes/CommonDita/xsl/fusion2fusionMap.xsl; Line#: 214; Column#: -1
JAVA: net.sf.saxon.trans.XPathException: Exception thrown by OutputURIResolver


<xsl:template match="chapter" >
<xsl:call-template name="dbg:trace"/>
<topichead>
<xsl:attribute name="id"><xsl:value-of select="@id"/>
</xsl:attribute>
<xsl:attribute name="navtitle"><xsl:value-of select="@title"/>
</xsl:attribute>
<xsl:variable name="map_file_name">
<xsl:call-template name="generatename">
<xsl:with-param name="title">
<xsl:value-of select="@title"/>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>

<mapref format="ditamap"
href="{$map_file_name}.ditamap"
scope="local" />
<xsl:variable name="map_filename_with_extn" select="concat($map_file_name,'.ditamap')" />
<xsl:message>map_filename_with_extn:<xsl:value-of select="$map_filename_with_extn"/></xsl:message>
<xsl:result-document
method="xml"
href="{$map_filename_with_extn}" doctype-system="map.dtd"
doctype-public="-//OASIS//DTD DITA Map//EN"
encoding="UTF-8"
indent="yes">
<map xml:lang="en">
<title>
<xsl:value-of select="@title"/>
</title>
<xsl:apply-templates />
</map>
</xsl:result-document>
</topichead>
</xsl:template>
Could you suggest any clue to fix the issue? Suspecting some thing wrong with href attribute value of xsl:result-document element. I am able to print the value of $map_filename_with_extn variable as expected.

Thanks,
Samba.
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: xsl:result-document : Invalid URI syntax: URI is not absolute

Post by Radu »

Hi Samba,

I would need more details about what the "TransformUsingXMLSchema" custom class does, how it works with the transformer, if you set a javax.xml.transform.stream.StreamSource for the XML content you should pass the system ID of the XML document in the stream source. The system ID needs to be an URL-like path like new File(/h/uaework/staging/docs/03/s20062603/en/Recruiting_Cloud.xml).toURI().toURL().toString() and not a file path.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
msambasiva
Posts: 87
Joined: Tue Jul 17, 2018 6:57 am

Re: xsl:result-document : Invalid URI syntax: URI is not absolute

Post by msambasiva »

Thanks Radu!. I will check on TransformUsingXMLSchema and get back to you!!
msambasiva
Posts: 87
Joined: Tue Jul 17, 2018 6:57 am

Re: xsl:result-document : Invalid URI syntax: URI is not absolute

Post by msambasiva »

Here is the java code used to transform,

Code: Select all

    void transform() throws Exception {
        // Since we're going to use a SAX feature, the transformer
        // must support input in the form of a SAXSource.
        TransformerFactory tfactory = TransformerFactory.newInstance();
        if(!tfactory.getFeature(SAXSource.FEATURE))
            throw new Exception("TransformerFactory can't do SAX features.");

        // Standard way of creating an XMLReader in JAXP 1.1.
        SAXParserFactory pfactory = SAXParserFactory.newInstance();
        pfactory.setNamespaceAware(true); // Very important!

        // Turn on validation.
        pfactory.setValidating(true);
            
        // Get an XMLReader.
        SAXParser parser = pfactory.newSAXParser();
        XMLReader reader = parser.getXMLReader();

        parser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
        reader.setErrorHandler(this);

        // Standard way of creating a transformer from a URL.
        Transformer t = tfactory.newTransformer(new StreamSource(xsltDoc));

        // Specify a SAXSource that takes both an XMLReader and a URL.
        SAXSource source = new SAXSource(reader, new InputSource(xmlDoc));

        // Transform to a file.
        t.transform(source, new StreamResult(htmlDoc));
    }
Can we get output folder path into xls file? Does it allow to create ditamap file using result-document element if we get the output folder location into xls?

Thanks,
Samba.
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: xsl:result-document : Invalid URI syntax: URI is not absolute

Post by Radu »

Hi Samba,

How are the "xsltDoc" and "xmlDoc" variables created? I do not see that in your sample code.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
msambasiva
Posts: 87
Joined: Tue Jul 17, 2018 6:57 am

Re: xsl:result-document : Invalid URI syntax: URI is not absolute

Post by msambasiva »

Those variables are strings as below,
String xmlDoc;
String xsltDoc;
String htmlDoc;
Thanks,
Samba.
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: xsl:result-document : Invalid URI syntax: URI is not absolute

Post by Radu »

Hi Samba,

I need to know the precise values you are assigning to them.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
msambasiva
Posts: 87
Joined: Tue Jul 17, 2018 6:57 am

Re: xsl:result-document : Invalid URI syntax: URI is not absolute

Post by msambasiva »

/uae/java/current/bin/java \
'TransformUsingXMLSchema' \
'/h/uaework/staging/docs/03/s20062603/en/Recruiting_Cloud.xml' \
'/h/uaework/custom/doctypes/CommonDita/xsl/fusion2dita.xsl' \
'/h/uaework/staging/docs/03/s20062603/en/Recruiting_Cloud/Recruiting_Cloud.ditamap' |
Radu
Posts: 9057
Joined: Fri Jul 09, 2004 5:18 pm

Re: xsl:result-document : Invalid URI syntax: URI is not absolute

Post by Radu »

Hi,

You are passing those paths as file paths instead of URL-like paths.
You need to create proper URL-like paths from them like:

Code: Select all

SAXSource source = new SAXSource(reader, new InputSource(new java.io.File(xmlDoc).toURI().toString()));
same for the other paths.
Other than that, if this will still not work I do not have any other ideas.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply