xml source with namespace

Hi when I use jav.io.InputStream to pass xml in subreport in 8.1.1 it returns empty pdf,

I understand the problem is the presence of namespace in xml,

I query ignoring namespace using version 8.0.2 it works perfectly,  (es 

<queryString language="XPath">
        <![CDATA[/xml/IHead/data/row]]>
    </queryString>

(xml is like <xml >         <Head >             <rs:data>.......</rs:data>        </Head ></xml >)

Now the same value of XPath retuns no value

how do i refer to node with namespace?

thks erika

erika.chinchio's picture
Joined: Feb 25 2021 - 2:06am
Last seen: 1 week 2 days ago

Thank you for posting to the Jaspersoft Community. Our team of experts has read your question and we are working to get you an answer as quickly as we can. If you have a Jaspersoft Professional Subscription plan, please visit https://support.tibco.com/s/ for direct access to our technical support teams offering guaranteed response times.
 

mrajkuma - 3 months 4 weeks ago

A jrxml sample would help understand this issue.

sanderse - 3 months 4 weeks ago

Dear User,

We are eagerly anticipating your response to the comment mentioned above. Please provide the requested information so that we can assist you in addressing your question effectively.

arai_4 - 3 months 3 weeks ago
show 1 more...

this is an example,

with TEST.XML (having namespace) it return empty page in jasperserver 8.1 and 8.2 (in the previus version it works well

with TEST2.XML (not having namespace) it return page with field printed

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport ........>
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="test"/>
    <parameter name="XML_INPUT_STREAM" class="java.io.InputStream">
        <defaultValueExpression><![CDATA[new java.io.FileInputStream($P{FilePath})]]></defaultValueExpression>
    </parameter>
    <parameter name="FilePath" class="java.lang.String">
        <defaultValueExpression><![CDATA["C:\\TEST.XML"]]></defaultValueExpression>
    </parameter>
    <queryString language="xPath">
        <![CDATA[/REPORTDATA/GRID/line]]>
    </queryString>
    <field name="NUMBER" class="java.lang.String">
        <fieldDescription><![CDATA[NUMBER]]></fieldDescription>
    </field>
    <field name="DESC" class="java.lang.String">
        <fieldDescription><![CDATA[DESC]]></fieldDescription>
    </field>
    <field name="DATE" class="java.lang.String">
        <fieldDescription><![CDATA[DATE]]></fieldDescription>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="37" splitType="Stretch">
            <textField>
                <reportElement x="40" y="7" width="482" height="30" uuid="f40d2e63-f14a-4f06-b65d-45ed08a0fbc5"/>
                <textFieldExpression><![CDATA[$F{DESC}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

erika.chinchio - 3 months 3 weeks ago

3 Answers:

this is an example,

with TEST.XML (having namespace) it return empty page in jasperserver 8.1 and 8.2 (in the previus version it works well)

with TEST2.XML (not having namespace) it returns correctly page with field printed in all versions

I assumed there was a behavior change with respect to reading namespaced fields

example: (attached xml to test)

--------------------------with namespace----------------------------

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport ........>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="test"/>
<parameter name="XML_INPUT_STREAM" class="java.io.InputStream">
<defaultValueExpression><![CDATA[new java.io.FileInputStream($P{FilePath})]]></defaultValueExpression>
</parameter>
<parameter name="FilePath" class="java.lang.String">
<defaultValueExpression><![CDATA["C:\\TEST.XML"]]></defaultValueExpression>
</parameter>
<queryString language="xPath">
<![CDATA[/REPORTDATA/GRID/line]]>
</queryString>
<field name="NUMBER" class="java.lang.String">
<fieldDescription><![CDATA[NUMBER]]></fieldDescription>
</field>
<field name="DESC" class="java.lang.String">
<fieldDescription><![CDATA[DESC]]></fieldDescription>
</field>
<field name="DATE" class="java.lang.String">
<fieldDescription><![CDATA[DATE]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="37" splitType="Stretch">
<textField>
<reportElement x="40" y="7" width="482" height="30" uuid="f40d2e63-f14a-4f06-b65d-45ed08a0fbc5"/>
<textFieldExpression><![CDATA[$F{DESC}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>

------------------without namespace

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport ........>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="test2"/>
<parameter name="XML_INPUT_STREAM" class="java.io.InputStream">
<defaultValueExpression><![CDATA[new java.io.FileInputStream($P{FilePath})]]></defaultValueExpression>
</parameter>
<parameter name="FilePath" class="java.lang.String">
<defaultValueExpression><![CDATA["C:\\TEST2.XML"]]></defaultValueExpression>
</parameter>
<queryString language="xPath">
<![CDATA[/REPORTDATA/GRID/line]]>
</queryString>
<field name="NUMBER" class="java.lang.String">
<fieldDescription><![CDATA[NUMBER]]></fieldDescription>
</field>
<field name="DESC" class="java.lang.String">
<fieldDescription><![CDATA[DESC]]></fieldDescription>
</field>
<field name="DATE" class="java.lang.String">
<fieldDescription><![CDATA[DATE]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="37" splitType="Stretch">
<textField>
<reportElement x="40" y="7" width="482" height="30" uuid="f40d2e63-f14a-4f06-b65d-45ed08a0fbc5"/>
<textFieldExpression><![CDATA[$F{DESC}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>

thks erika

Attachments: 
AttachmentSize
File test2.xml527 bytes
File test.xml581 bytes
erika.chinchio's picture
Joined: Feb 25 2021 - 2:06am
Last seen: 1 week 2 days ago

I notice 2 things

- in the namespace version of the xml you have not defined the namespaces.

- In  Studio when defining the xml adapter, is the "Enable namespaces support" checkbox marked? 

sanderse's picture
4507
Joined: Jul 31 2017 - 3:51pm
Last seen: 5 hours 52 min ago

thks for your replay

 but I try to define namespace and marked "enable namespaces support" in adapter, but in jasperserver I see pdf empty,

in the previuos version of jasper the same example works well

thks erika

erika.chinchio's picture
Joined: Feb 25 2021 - 2:06am
Last seen: 1 week 2 days ago
Feedback
randomness