On Oct 24, 2008, at 12:59 PM, Recoil wrote:


Shoot, you're talking about using xsl to generate the entire page,
yes?

No, you target an ID to put the transformed result into.



On Oct 24, 11:37 am, Recoil <[EMAIL PROTECTED]> wrote:
Hmmm, I haven't used XSL before, I'm looking it up right now, but I'm
a bit unclear as to where to go from the point where I apply the XSLT
to the XML. I mean, is this just automatically going to 'work'?

On Oct 24, 7:19 am, Robert Koberg <[EMAIL PROTECTED]> wrote:

On Oct 23, 2008, at 11:09 PM, Recoil wrote:

Only thing is, I want the article text to be xhtml-enabled. so there's
<b>'s and <br/>'s and such in there, and we're looking at something
more like

<article>
      <title>This title is rad.</title>
      <text>
      And this is some <b>awesome</b> article text.<br/>
      It's HTML formatted though, <i>that could pose a problem</i>.
      </text>
</article>

I want to grab ALL of the text content inside of the <text> node, and
just carte blanche throw it in the page.

No, from what you say below you don't want the text, you want all the
nodes: text, elements, etc.

So.. how can I do that? .text() strips out all the html
entities, .html() works what I can best describe as 'intermittently',
and is unsupported for xml documents (only supported for html
docs).... what can i use to just tell js/jquery to "find everything
between <text> and </text>, and stick it in the DOM as xhtml, tags
included"?

The *best* way to handle this type of thing (if you are up for it) is
to use XSL, which works in all browsers. You are looking for the a
modified 'identity transform'. Basically, a modified identity
transform allows you to recursively copy everything you do not
override by a template match.

An example XSL that does what you want:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">

   <xsl:template match="/">
     <xsl:apply-templates/>
   </xsl:template>

   <xsl:template match="article">
     <div class="article" xmlns="http://www.w3.org/1999/xhtml";>
       <xsl:apply-templates/>
     </div>
   </xsl:template>

   <xsl:template match="title">
     <h1 xmlns="http://www.w3.org/1999/xhtml";>
       <xsl:apply-templates/>
     </h1>
   </xsl:template>

   <xsl:template match="text">
     <xsl:apply-templates/>
   </xsl:template>

<!-- Identity template: copies everything not overridden/ matched in
other templates -->

   <xsl:template match="@*|node()">
     <xsl:copy>
       <xsl:apply-templates select="@*"/>
       <xsl:apply-templates/>
     </xsl:copy>
   </xsl:template>

</xsl:stylesheet>

Reply via email to