Jump to content

import other xml into xsl


maveric2k2

Recommended Posts

Hello!I already have an XML and a matching XSL. Now i have the following problem:XML1 ?XML2 | | \/ \/ XSL | \/ HTML / otherI have successfully used the following lines:<xsl:variable name="hxml">./<xsl:value-of select="$p_libname" />/<xsl:value-of select="module/mname" />_hier.xml</xsl:variable><xsl:variable name="hroot_nm"><xsl:value-of select="document($hxml)/hier_module/name"/></xsl:variable>output_name: <xsl:value-of select="$hroot_nm" />==================output_name: blablaNow everything works fine, but when the XML2 file is missing i've got an error.How can i prevent the "file not found error"?I've tempted the following:<xsl:if test="document($hxml)"> <xsl:variable name="hroot_nm"><xsl:value-of select="document($hxml)/hier_module/name"/></xsl:variable> <xsl:value-of select="$hroot_nm" /></xsl:if>The error still occure! :) ======================================================================By the way, is it possible to link a variable to the XML2 root?like:<xsl:variable name="hxml">./<xsl:value-of select="$p_libname" />/<xsl:value-of select="module/mname" />_hier.xml</xsl:variable><xsl:variable name="hroot"><xsl:value-of select="document($hxml)"/></xsl:variable>name: <xsl:value-of select="$hroot/hier_module/name" />description: <xsl:value-of select="$hroot/hier_module/description" />params: <xsl:apply-templates select="$hroot/hier_module/params" />========name: blabladescription: blablaparams: bla1, bla2, bla3, ...thx, mav.

Link to comment
Share on other sites

I'm not sure I understand you completely. As it is, you have provided some weird kind of code(the "./" consuses me) and it's not completely clear what are you asking for.You should make some more "isolated" test to see if it's possible to call a variable inside a variable. In fact, I think of making ones actually :) .the document() function should refer to a URL, not to a variable. If the URL's value is suppose to be the same as a variable, I think you could use brackets( "{" and "}") around the variable's name. Like

<xsl:if test="document({$hxml})">

However I must say that putting a variable as part of an XPath expression is an issue I'm still trying to figure out, so this might not work. Hmm... anyway... if the above doesn't work, try it like this:

<xsl:if test="document({$hxml})/*">

This would mean if there is any element inside the pointed file. After all, IFs usually adress nodes and attribute values as it is. I don't know if they could also check for files.

Link to comment
Share on other sites

Hello boen_robot!Ok. , let me explain this:I only want to load an other XML when i process XML1. I like to have a complete copy of the XML2 into a new node!? After that i want to access this node and handle it like the XML1 root node.like this:newnode = load XML2$newnode/name$newnode/blablaxsl:apply-templates select="$newnode/params...Bye,mav

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...