XSLT Document() Function results in Saxon Error/ Attribute-String cant be used as Filepath

可紊 提交于 2019-12-24 11:36:09

问题


Basic Information is I have a Element with an ID

I want to use the ID-Attribute within the document()-Function to extract the content of the -element

I have two Problems here:

1) my saxon Processor wont resolve any fixed! Filepath I provide within de Document Function

-->RESULT: FODC0005 Document has been marked not available: Filepath

Question: Why ???

This is my code so far:

<xsl:template match="pmentry"><xsl:apply-templates/></xsl:template>

<xsl:template match="refdm"><xsl:apply-templates/></xsl:template>

<xsl:element name="datamodule">

<xsl:element name="DMC">DMC-<xsl:value-of select="modelic"/>-<xsl:value-of select="sdc"/>-<xsl:value-of select="chapnum"/>-<xsl:value-of select="section"/><xsl:value-of select="subsect"/>-<xsl:value-of select="subject"/>-<xsl:value-of select="discode"/><xsl:value-of select="discodev"/>-<xsl:value-of select="incode"/><xsl:value-of select="incodev"/>-<xsl:value-of select="itemloc"/>
</xsl:element>

<xsl:element name="CSH">
<xsl:attribute name="ID">DMC-<xsl:value-of select="modelic"/>-<xsl:value-of select="sdc"/>-<xsl:value-of select="chapnum"/>-<xsl:value-of select="section"/><xsl:value-of select="subsect"/>-<xsl:value-of select="subject"/>-<xsl:value-of select="discode"/><xsl:value-of select="discodev"/>-<xsl:value-of select="incode"/><xsl:value-of select="incodev"/>-<xsl:value-of select="itemloc"/></xsl:attribute>

<xsl:value-of  select="document(concat('../XML/',@ID,'.xml'))/dmodule/idstatus/status/remarks"/>
</xsl:element>


</xsl:element>

</xsl:template>

2) My second Problem is, I couldn't figure out how to use my ID as the Filename

If anyone has a tip or something i'm really clueless how to do it.

Thanks in advance

Edit: the 3 document()-Function have been for testing where Saxon starts searching the doc

Edit:

So I'm Working in the following Folder setup:

Folder Playground: Subfolder XSLT and XML

The Batch File is on the same Level as the Folders

 java -jar XSLT/saxon9he.jar -s:FLARE_Publicationmodul.xml -o:XSLT/remark_list.xml  -xsl:XSLT/read_remarks_part1.xsl 

now my Plan is to generate this XML-File:

<?xml version="1.0" encoding="utf-8"?>
<list>
<datamodule>
<DMC>DMC-S1000DBIKExsd-AAA-01-00-0000-00A-001A-A</DMC>
<CSH ID="DMC-S1000DBIKExsd-AAA-01-00-0000-00A-001A-A"> Content of the Remarks Element</CSH>
</datamodule>

<datamodule>
<DMC>DMC-S1000DBIKExsd-AAA-D00-00-00-00AA-941A-D</DMC>
<CSH ID="DMC-S1000DBIKExsd-AAA-D00-00-00-00AA-941A-D"> Content of the Remarks Element</CSH>
</datamodule>

...

</list>

So the concat path should simply look like this:

../XML/DMC-S1000DBIKExsd-AAA-D00-00-00-00AA-941A-D.xml

The Path should be right. Saxon prints them in th console, but the @ID information is missing, or if i supply a fixed path like (../XML/1.xml) he checks the Folder but dosent find a file.

Is it possible I have to enable the document Function in Saxon9he?

Or is there an other solution to extract Element Content from other Files?

Thanks for your Help


回答1:


A document (more precisely, a URI) is "marked as unavailable" under two circumstances:

(1) you call doc-available() supplying that URI, and the answer is false

(2) you call doc() or document() supplying that URI, and an error occurs.

In case (2), you will normally see the original failure on the first attempt to access the URI, so unless you have used try/catch to suppress the error, this is unlikely. Does your stylesheet use doc-available()?

Your experiments seem to suggest that you haven't quite worked out how relative URIs get resolved. The rule for document() is:

  • If you supply a node, for example document(@ID) then the relative URI in @ID is resolved against the base URI of the element where the node was found (that is, typically, the URI of the source document of the transformation)

  • If you supply a string, for example concat(@ID, '.xml'), then the relative URI is resolved against the base URI of the stylesheet.

You can check the base URI of the source document by outputting base-uri(.), for example; and you can check the base URI of the stylesheet using static-base-uri(). Problems sometimes arise because the base URI isn't known; this can happen for example if the input to the transformation is supplied as a DOM.

I hope this helps you to move forward. If you still have problems, we will need to know

(a) what the argument to document() was

(b) what the base URI of the source document and stylesheet were

(c) what is the full path of the file you expect to be reading



来源:https://stackoverflow.com/questions/33033326/xslt-document-function-results-in-saxon-error-attribute-string-cant-be-used-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!