0

Getting error

java.lang.NullPointerException: null
at net.sf.saxon.event.ReceivingContentHandler.startPrefixMapping(ReceivingContentHandler.java:291)

in Camel Java DSL project when im trying to transform xml with xslt. This xslt works perfectly in oxygen editor with saxon,, but when i use same xslt in apache camel with java project for transformation getting above exception. Is there any way i can solve this with java and camel project. I used saxon HE 9 as dependency also.

XML ::::

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Lowdtl xmlns="http://domain/crd/bdr/services/get">
    <PreDtl>
        <LowestDtl>
            <Otpxyz abc="000" xyz="NPS" yahoo="0" temp="" />
            <Otpxyz abc="001" xyz="NPS" yahoo="0" temp="" />      
        </LowestDtl>
        <HighDtl>
            <linkDtl>
                <Otpxyz abc="000" xyz="NPS" yahoo="0" temp="" />
                <Otpxyz abc="001" xyz="NPS" yahoo="0" temp="" />
              </linkDtl>
            <HighDtl>
                <BinDtl>
                    <RestLin abc="003" xyz="NPS" yahoo="0" temp=""  />
                </BinDtl>
                <DatDtl>
                    <DatCd abc="003" xyz="NPS" yahoo="0" temp=""  />
                </DatDtl>
            </HighDtl>
        </HighDtl>
    </PreDtl>
    <RemoveDtl abc="003" xyz="NPS" yahoo="0" temp=""  >
        <Ts SysTs="2019-10-29 07:54:43.520" />
        <RemoveMsg>
            <rmv abc="003" xyz="NPS" yahoo="0" temp="" />
        </RemoveMsg>
    </RemoveDtl>
</Lowdtl>

XSLT ::

<xsl:stylesheet version="2.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xpath-default-namespace="http://domain/crd/bdr/services/get">
    <xsl:output method="xml" indent="yes" />
    <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="RemoveDtl" />
</xsl:stylesheet>
user207421
  • 305,947
  • 44
  • 307
  • 483
redyabkees
  • 13
  • 4

1 Answers1

1

It would be useful to have a stack trace at the point of the exception, and it would also be useful to know exactly what Saxon version is being used.

The line number suggests that it's probably the most recent version (9.9), in which case it is crashing because a null value has been supplied for the prefix in a call to the method startPrefixMapping(prefix, uri). This method implements the SAX interface org.xml.sax.ContentHandler, and although the spec for this method [1] doesn't explicitly say what happens if you pass null, it doesn't define any meaning for null, and therefore throwing an NPE is reasonable.

So we need to find out why the caller has supplied a null prefix, and the first step in doing that is to get the stack trace and find out who the caller is. Normally this method is called by an XML parser (an implementation of XMLReader) and these are generally pretty robust and reliable; however sometimes user-written code appears on the processing pipeline as a proxy for the XMLReader, and this can be more erratic.

==LATER==

The symptoms look the same as this known Camel bug:

https://issues.apache.org/jira/browse/CAMEL-10704

Check that you are using a version of Camel containing the fix.

[1] https://docs.oracle.com/javase/7/docs/api/org/xml/sax/ContentHandler.html#startPrefixMapping(java.lang.String,%20java.lang.String)

Michael Kay
  • 156,231
  • 11
  • 92
  • 164