xsl-list
[Top] [All Lists]

[xsl] is there a way to output XML with invalid qnames?

2009-11-06 19:59:26
I'm trying to format XML files so that I can display them as examples in a 
wiki. I'd like the element names in the examples to link to other wiki pages, 
so I'm trying to figure out the best way to take source like this:

<ns:elementName1>
    <ns:elementName2>value</ns:elementName2>
</ns:elementName1>


And get output like this:

<[ns:elementName1|page 1]>
    <[ns:elementName2|page 2]>value</ns:elementName2>
</ns:elementName1>

Of course, "[ns:elementName|page]" isn't a valid qname so just trying to rename 
the elements in an XML to XML transform doesn't work. 

I've messed around a bit trying to output HTML that looks the way I want it to 
look, including indentation, eg:

<xsl:for-each 
select="rss/channel/title|rss/channel/link|rss/channel/description">
      <xsl:variable name="value" select="text()" />
      <xsl:variable name="name" select="name()" />
      <xsl:variable name="newName" select="concat($open, $name, $linkEnd)" />
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;<xsl:value-of 
select="$newName"/>&gt;<xsl:value-of select="$value"/>&lt;/<xsl:value-of 
select="$name"/>&gt;<br />
</xsl:for-each>

That works fine for simple inline elements, but it I'm not sure how to deal 
with nodes with children.

Before I give myself a headache trying to figure it out, I was wondering if 
anyone could suggest a better approach I should look into.

            
    



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>