views:

53

answers:

1

I've stored a file's tree into $onto

<xsl:variable name="onto" select="document('file.xml')"/>

In some places I can use this variable as espected:

<xsl:copy-of select="$onto/rdf:RDF"/>

But I'm having trouble in other places, strange chars are written on output:

<xsl:element name="autor">
     <xsl:attribute name="rdf:resource">

     <xsl:text>#</xsl:text> <xsl:value-of select="$onto"/>
     </xsl:attribute>
</xsl:element>

This is the beginig of the output I've got:

<autor rdf:resource="#&#10;  &#10;  &#10;    &#10;      &#10;    &#10;  &#10;  &#10;    &#10;      &#10;    &#10;  &#10;  &#10;    &#10;      &#10;    &#10;  &#10;  &#10;  &#10;    &#10;  &#10;  &#10;    &#10;      &#10;    &#10;  &#10;

What I'm missing? What's wrong? If that's to much for an attribute, what can I do? Thank you

A: 

When <xsl:value-of> is applied to a tree fragment, it takes the text content of that tree. In your case, it looks like your XML file doesn't contain any text (other than whitespace) which isn't in an attribute value. I suspect that you mean to select the value of a particular attribute node within the document, e.g.:

<xsl:value-of select="$onto//foo/@bar"/>

(Without knowing the structure of your XML and what you're trying to select, I don't know what the real path would be.)

Ben Blank