Parse xml resolving an external ENTITY reference using XML Viewer webpart

Mapple Leaf 1 Reputation point
2021-06-18T02:03:11.2+00:00

Hello Everyone,

This is related to the OOTB XML view web part. The parser is having an issue displaying XML when an external entity is added to the XML file. Below is a sample code for reference. The external entity ISOEntities for example resolves special characters such as & ’ − in the description node.

<?xml version="1.0" encoding="UTF-16"?>

<!DOCTYPE root[
<!ENTITY % ISOEntities PUBLIC "ISO 8879-1986//ENTITIES ISO Character Entities 20030531//EN//XML" "http://www.s1000d.org/S1000D_4-0-1/ent/ISOEntities">
%ISOEntities;
]>
<root>
<description> This is description &</description>
</root>

I am using the following XSLT for display:

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

<xsl:template match="/">
<html>
<body>
<h1>Description:<xsl:value-of select="root/description" disable-output-escaping="yes"/></h1>
</body>
</html>
</xsl:template>

</xsl:stylesheet>

The XML view web part is not displaying anything when an encoded special character is present in the XML node

I would like to know whether any restriction for accessing public external entity (special characters) is put by SharePoint Framework for XML parser (used for XML Viewer web part)? If yes, how can be we change settings in the XML Viewer web part to support external entities?

Could you please suggest how to resolve this issue?

Thank you very much for your support.

Regards,

ML

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,685 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,971 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Mapple Leaf 1 Reputation point
    2021-06-18T04:10:07.223+00:00

    Also, I appreciate it if someone can help me to locate the logs for the XML view web part.

    Thank you very much.

    0 comments No comments

  2. MichaelHan-MSFT 18,031 Reputation points
    2021-06-21T08:01:40.897+00:00

    Hi @Mapple Leaf ,

    Per my test, if there was a DOCTYPE defined for the XML, the XML view web part would not work. We need to remove the doctype in the xml.

    Below is my test result:

    xml:

    <?xml version="1.0"?>  
    <root>  
    <description> This is description &amp;</description>  
    </root>  
    

    xsl:

    <?xml version="1.0" encoding="UTF-8"?>  
    <xsl:stylesheet version="1.0"  
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  
    <xsl:template match="/">  
    <html>  
    <body>  
    <h1>Description:<xsl:value-of select="root/description"/></h1>  
    </body>  
    </html>  
    </xsl:template>  
    </xsl:stylesheet>  
    

    107505-image.png


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.