1

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
  • Please show a sample of the XML element with its ID value, then tell us exactly which file name or URI you want to create and load. Also consider to run Saxon with the -t option as it then gives more detailed error diagnostics as to which files it tries to load. Commented Oct 9, 2015 at 8:38

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

6 Comments

You still haven't told us anything about the source document to the transformation, or about the base URIs of the source document and stylesheet.
What do you mean with source document? the Publicationmodul (-s in the comand line) or the XML-Module from which I want to extract the Element ?
The Path to the Files are always: C:/User/Desktop/Playground/XSLT/stylesheetname.xsl C:/User/Desktop/Playground/XML/DMC-XXXXXx-XXXx-xxx.xml C:/User/Desktop/Playground/Publicationmodule_Flare.xml (source) C:/User/Desktop/Playground/XSLT/remarks_list.xml (output)
The main problem at the moment is that The ID (filename) doesn't appear in the generated Path and I use concat like everybodyelse. If Saxon prints out that it couldnt find the File C:/ users/playground/XML/DMC-AAA-000-etc-etc.xml its a step in the right direction.
@Humfre, I think this is the first time you have mentioned the "Publicationmodul" and the "XML-Module". I don't know what these are. We can't help you unless you give more information about what you are doing. Preferably, reduce it to a simple runnable example.
|
-1

I think, it is error in Saxon.

But there is workaround :-) :

    <xsl:function name="fix:doc" as="document-node()?" visibility="final">
        <xsl:param name="fix:uri" as="xs:string?" required="yes"/>
        <xsl:if test="exists( $fix:uri )">
            <xsl:source-document href="{ $fix:uri }">
                <xsl:sequence select="/"/>
            </xsl:source-document>
        </xsl:if>
    </xsl:function>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.