I have the following component (only the relevant part of the component's source is shown):
<ParagraphCenter xmlns="http://www.sdl.com/web/schemas/core">
...
<bodyText>
<text>
<p xmlns="http://www.w3.org/1999/xhtml">
<a xmlns:xlink="http://www.w3.org/1999/xlink" title="Linked component 1" xlink:href="tcm:184-112533" xlink:title="Linked component 1">Linked component 1</a>
</p>
</text>
</bodyText>
<ctaButton>
<linkText>text</linkText>
<internalLink xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="tcm:184-112534" xlink:title="Linked component 2"></internalLink>
<altText>text</altText>
</ctaButton>
...
</ParagraphCenter>
When outputing the field using @Html.DxaRichText()
the tag's href property remains unresolved, and the xlink attributes are not cleaned up:
<a title="Linked component 1" xlink:href="tcm:184-112534"
xlink:title="Linked component 2" xmlns="http://www.w3.org/1999/xhtml"
xmlns:xlink="http://www.w3.org/1999/xlink">Linked component 1</a>
Debugging showed that issue is in the ResolveRichText()
of the DefaultRichTextProcessor.cs
, specifically on line
foreach (XmlElement linkElement in doc.SelectNodes("//a[@xlink:href]", nsmgr))
In the source of the component, <a>
has a namespace of http://www.w3.org/1999/xhtml
, so when using the following instead of the original line
foreach (XmlElement linkElement in doc.SelectNodes("//xhtml:a[@xlink:href]", nsmgr))
the <a>
gets processed properly.
My question is, did anyone encounter this before? What is the source of the mismatch on the xml <-> xpath relation, CM or DXA? Any advices on how to resolve this? I can always resolve the link in the views, but I'd rather have it done the way it's supposed to be.
Important to state that the component link in the RTF is added through the ribbon RTF editor. Version of CMS is Web 8.2 coupled with Dxa v1.5
There were a couple of similar questions already, but this situation is different:
- the linked component is published is resolved properly to a page from the
internalLink
field (this was the issue here) - the href attribute does have the xlink namespace prefix (this was the issue here)
Thank you in advance.