[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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


Subject: [xsl] is there a way to output XML with invalid qnames?
From: Jessica Britton <jessica.britton@xxxxxxxxxxxxxxx>
Date: Fri, 6 Nov 2009 16:57:46 -0800

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.

           
   


Current Thread
Keywords
xml