Jump to content

Getting value of unparsed entity in spawned node document fragment


Recommended Posts

I have a some System Entities defined our my Master xml (that has entity references to contained xml's) that I use to get image locations using (unparsed-entity-ur). Which works fine, except for the case where the xml has a figure object with comments:note attribute, and then a contained <graphic> which uses entity reference to resolve the image source. Without the comment:note of the figure, it resolves fine. The problem is my comment xslt template creates a document fragment of the node containing the comment without the comment attribute resulting from xsl copy-of function, so it is now not connected to the main document anymore, so when it is done transforming the content, when trying to resolve 'unparsed-entity-uri' returns blank. So, my question is, is there anyway to still reference the entity, or pass the value/reset the value/set value to another parameter/etc around this new document fragment so that I can still get the source value of the image? The xsl calls are below that creates the new document fragment. For the graphic tag, which occurs after the comment, have another template where I call the 'unparsed-entity-uri' of a name passed in from the xml, but just returns blank. <xsl:template>.... <xsl:variable name='decommented-node'> <xsl:call-template name='decomment'> <xsl:with-param name="node" select='.' /> </xsl:call-template> </xsl:variable> <!-- Apply the template for the decommented node. Need to drill down into the document fragment that contains that node. And, for good measure, pick the first child. --> <xsl:apply-templates select='$decommented-node/*[1]'/> </xsl:when> <xsl:otherwise> <!-- We haven't yet shown title. Process all nodes. --> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <!-- Do NOT render --> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name='decomment'> <xsl:param name='node' select='.'/> <xsl:element name='{name($node)}'> <xsl:for-each select="$node/*[name()!=title]|text()|$node/@*[name()!=comment]"> <xsl:copy-of select="."/> </xsl:for-each> </xsl:element> </xsl:template>

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...