xsl-list
[Top] [All Lists]

RE: [xsl] Replace content of element, then transform it...

2012-08-30 07:58:23

So I tried this

<xsl:template match="body">
         <body>
             <xsl:value-of select="." disable-output-escaping="yes"/>
         </body>
     </xsl:template>

     <xsl:template match="leadtext">
         <leadtext>
             <xsl:value-of select="." disable-output-escaping="yes"/>
         </leadtext>
     </xsl:template>


     <xsl:template match="node()|@*">
         <xsl:variable name="foo">
         <xsl:copy>
             <xsl:apply-templates select="node()|@*"/>
         </xsl:copy>
         </xsl:variable>
         <xsl:apply-templates select="$foo" mode="phase2" />
     </xsl:template>
<!-- Error message:
Description: Cannot create an attribute node (id) whose parent is a 
documen= t node
-->

After reading about how this works, I now understand why I am getting the e= 
rror. Is there another alternative to make this possible in one document, o= 
r do I have to send the output to a new document?

Consider to show us minimal but complete XML input and XSLT code samples 
causing that error, then we should be able to help.

This is minimal but complete XML below.

<release id="66783" lang="fi">
    <!--Body text for a release, HTML (in XML-encoded form)-->
    <body>&lt;p&gt;&lt;span&gt;"Lorem ipsum dolor sit 
amet.&lt;/span&gt;&lt;/p&gt;
        &lt;p&gt;&lt;span&gt;"Lorem ipsum dolor sit amet.&lt;/span&gt;&lt;/p&gt;
        &lt;p&gt;&lt;span&gt;"Lorem ipsum dolor sit 
amet.&lt;/span&gt;&lt;/p&gt;</body>
    <!--Boilerplate text for the release, plain text-->
    <boilerplate>Boiler plate: Lorem ipsum dolor sit amet, consectetur 
adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna 
aliqua. Ut enim ad minim venia</boilerplate>
    <!--Possible contact persons for the release as plain text-->
    <contactsAsText/>
    <!--Embargo, used pattern is dd.MM.yyyy HH:mm-->
    <embargo/>
    <!--Possible keywords for a release, free text-->
    <keywords>test solita</keywords>
    <!--Lead text for a release, HTML (in XML-encoded form)-->
    <leadtext>Lorem ipsum dolor sit amet.</leadtext>
</release>

Trond Husø

-- 

        Martin Honnen --- MVP Data Platform Development
        http://msmvps.com/blogs/martin_honnen/

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


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