Error attempting to use MarkupParserExtension

Topics: XSLT
May 11, 2011 at 9:29 PM

Hi there.

I have a Page Metatype (Spotlights) that contains 3 fields (Title - String, Image - C1 Image Reference, and Content - String using the VisualXhtmlEditor )

I created an XSLT function to only display these fields if the Title is set (along with the markup).  I was able to get it to work without any issue, except that it was quoting all the html stored in Content, so I found this:

So I went ahead and added the Function Call to Composite.Xslt.Extensions.MarkupParser, and my xslt code is like this:

<xsl:variable name="content" select="/in:inputs/in:result[@name='GetSpotlightsXml']/Spotlights/@Content" />

<xsl:value-of select="Parser:ParseXhtmlBodyFragment($content)" xmlns:Parser="#MarkupParserExtension" xmlns:xsl="" />

I get the following error:

Error: Cannot find a script or an extension object associated with namespace '#MarkupParserExtension'.
Error details:
Failed to get value for function 'ITD.RenderSidebar'
Cannot find a script or an extension object associated with namespace '#MarkupParserExtension'.

This happens even if I put the xmlns:Parser attribute on the outer xsl:stylesheet tag.  I've been sort of stuck on this one problem for a while now, any help would be appreciated.

May 11, 2011 at 9:34 PM

@hrplex you have to add a function call Composite.Xslt.Extensions.MarkupParser

May 11, 2011 at 9:39 PM


I already have that function call added to my xslt function.  But I still get the error.

May 11, 2011 at 10:17 PM

Could you post the "input XML" you get when previewing? (if it has verbose data, feel free to shorten that part, I'm looking for the comments relating to the extension).

May 12, 2011 at 2:57 PM


Looking at the input tab I noticed in the comments:

    <!-- Function call result 'MarkupParser' has been registered as an Xslt Entension Object. -->
    <!-- Extension methods can be called using the namespace '#MarkupParserExtensions'. -->
    <!-- The following methods exist: -->
    <!-- XPathNavigator ns:ParseWellformedDocumentMarkup(String wellformedMarkupString) -->
    <!-- XPathNavigator ns:ParseXhtmlBodyFragment(String xhtmlBodyFragmentString) -->

It appears the problem was that I followed the example here:

Which says "MarkupParserExtension" instead of MarkupParserExtensions".

Anyways, another problem has arisen.  As I mentioned before, I have a Content property on my metatype, which uses the VisualXhtmlEditor.  When I edit the page and that metatype, I should have my thing in p tags, but when I render it with either ParseXhtmlBodyFragment or ParseWellformedDocumentMarkup, the p tags get stripped out.  Any idea why this is happening?  Or if I want to do what I am doing, should I be doing it differently?

Initially I just used a visual function, which works fine, but then I can't have the logic to only display it if the Title is set...

May 12, 2011 at 3:30 PM

I can see we have multiple fails in that FAQ post - sorry about that :(

Beside from using the namespace #MarkupParserExtensions, use this XLST:

<xsl:copy-of select="Parser:ParseXhtmlBodyFragment(@LongDescription)" xmlns:Parser="#MarkupParserExtensions" xmlns:xsl="" />
Let me know if this works okay - we will get the FAQ post fixed asap.

May 12, 2011 at 3:55 PM

I am already using ParseXhtmlBodyFragment, but it still filters out the p tags for some reason.

When I edit the Content property for my meta type, when I view the source, I clearly see the multiple paragraphs of text surrounded by p tags.  But when I use ParseXhtmlBodyFragment, they get stripped out.  What am I doing wrong?

May 12, 2011 at 4:02 PM

use xsl:copy-of instead of xsl:value-of

May 12, 2011 at 4:06 PM

Doh, sorry I missed that part.  That did it, thanks a lot for your help!