Nodes in an XML Document

I have developed an xml schema to parse an incoming XML document. The receiving location receives XML documents from 2 channels, one of which has the spelling node in the document "Roookie" instead of "Rookie". Is there a way for my existing xsd to parse this document?

0


source to share


4 answers


You can probably preprocess the wrong XML file, for example with this simple XSL stylesheet:



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

<xsl:output method="xml" indent="no"/>

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

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

</xsl:stylesheet>

      

+2


source


You will need to replace elements in the document or change the xsd to work with the new document format.



0


source


Just change your schema to accept the choice between two nodes (Rookie or Roookie), not just 1 node named Rookie. Both nodes are of the same type. Of course, if Roo (o) kie has complex content, then you need to declare a complex type for that content to avoid duplicating the entire structure of the two elements.

0


source


Onyl's answer is to change the bad message. Xsd is a contract and must be respected through dispatch systems. If you do not have this control over the feeding systems, I would suggest making a second circuit with a new name and taking into account its spelling error. I'll start modifying your contract / xsd for every error in the post, you will increase the complexity and decrease the maintainability.

0


source







All Articles