|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
document() with missing files
im using document() to link to related xml files. The problem i am having is when one of the linked documents is missing.
What i wanted to do was have a copy of the seperated related documents on cd so they still worked (just with the related bits missing) without needing to modify the xsl file. Is there a way in xsl to check if a file exists before trying to open it for information? |
|
#2
|
|||
|
|||
|
ok i think im on to a possible solution but im still getting a lot of errors.
Here is the idea: Put the information i want to display (linked to the alternative xml file) in a variable. Use an if condition with fallback so if the fallback is used then the variable is changed so it no longer links to the other xml file Display the variable. Now the problems i am having are that i cannt seem to get variables working (ive not really messed with this much) and more importantly, fallback does not work at all if its used with document() for some reason. Ive searched on google for help regarding this but from what ive found fallback should work. Code:
<xsl:if test="document(file)"> <xsl:fallback> The file does not exist </xsl:fallback> </xsl:if> The way im testing this is to run the xml with the folders im linking to renamed (add an extra random letter). The system works fine if they are named properly but i still get the usual errors if they are renamed (rather than the code in the fallback) any ideas what im doing wrong? |
|
#3
|
|||
|
|||
|
I think ive made some progress with the problem, with the following:
Code:
<xsl:variable name="test" select="c:/file.xml"/>
<td><xsl:value-of select="$test"/></td>
<xsl:choose>
<xsl:when test="boolean(document(string(concat('', $test, ''))))">
working
</xsl:when>
<xsl:otherwise>
not working
</xsl:otherwise>
</xsl:choose>
IE displays a The XML page cannot be displayed error and stops. If i use mozilla then the code works fine. I would use mozilla now instead but i found that mozilla does not follow xml links on a php page (unless i copy the shortcut and paste into address bar). Is there a way to turn of the XML errors in IE so it works like in mozilla? (or make mozilla work with XML links properly) |
|
#4
|
|||
|
|||
|
i sorted the xml links in mozilla, it was relating to a security issue.
To turn this off i went to about:config, found security.checkloaduri and changed its value from true to false |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > document() with missing files |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|