あなたはおそらく記録上のループ
<queryString language="XPath">
<![CDATA[/records/record]]>
</queryString>
を定義するには、あなたのXPathクエリがされるように好きなあなたは自分の例では、XPathクエリ
に対するあなたのフィールドを定義していない特別な設定はありませんあなたはfieldDescription
<field name="keywords" class="java.lang.String">
<fieldDescription><![CDATA[metadatas/keywords]]></fieldDescription>
</field>
を使用keywords
を指す場名前は任意であり、クラスは、Javaの値の表現であるとfieldDescriptionは、次いで、この第一defining your data adapterことによって達成されるJasperSoft StudioでのqueryStringに
JasperSoftメーカー
に関連したノードの相対パスでありますレポートノードを右クリックし、[データセットとクエリ]を選択します。ダイアログでは、あなたのデータアダプタを選択し、XPathは、その後、あなたがフィールドとして追加するフィールドを、あなたのXPathクエリを記述し、クリックし
全jrxml例
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="XMLTest" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="b487729d-4510-4485-b838-19c491042208">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="XMLTest"/>
<queryString language="XPath">
<![CDATA[/records/record]]>
</queryString>
<field name="title" class="java.lang.String">
<fieldDescription><![CDATA[metadatas/title]]></fieldDescription>
</field>
<field name="description" class="java.lang.String">
<fieldDescription><![CDATA[metadatas/description]]></fieldDescription>
</field>
<field name="keywords" class="java.lang.String">
<fieldDescription><![CDATA[metadatas/keywords]]></fieldDescription>
</field>
<columnHeader>
<band height="20" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<staticText>
<reportElement x="0" y="0" width="170" height="20" uuid="3ce3004b-8324-4f57-ba9f-77cdffc711da"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[title]]></text>
</staticText>
<staticText>
<reportElement x="170" y="0" width="170" height="20" uuid="6ee7c571-ecdc-45cc-b11d-600099121301"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[description]]></text>
</staticText>
<staticText>
<reportElement x="340" y="0" width="210" height="20" uuid="111fa52f-bc0b-4698-8ba9-a7af03988254"/>
<textElement verticalAlignment="Middle">
<font isBold="true"/>
</textElement>
<text><![CDATA[keywords]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="20" splitType="Stretch">
<property name="com.jaspersoft.studio.unit.height" value="pixel"/>
<textField>
<reportElement x="0" y="0" width="170" height="20" uuid="444010e8-18ce-4594-a1b1-ca3d120b091d"/>
<textElement verticalAlignment="Middle">
<font isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{title}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="170" y="0" width="170" height="20" uuid="9a27a707-c5df-4905-ac21-e42b21c1d77c"/>
<textElement verticalAlignment="Middle">
<font isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{description}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="340" y="0" width="210" height="20" uuid="1621de6d-7200-49aa-a0d4-56f64fec1b91"/>
<textElement verticalAlignment="Middle">
<font isBold="false"/>
</textElement>
<textFieldExpression><![CDATA[$F{keywords}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
例データソース
<records>
<record>
<metadatas>
<title>first title</title>
<description>descriptions</description>
<keywords />
</metadatas>
</record>
<record>
<metadatas>
<title>second title</title>
<description>descriptions 2</description>
<keywords>test, hello</keywords>
</metadatas>
</record>
</records><records>
<record>
<metadatas>
<title>first title</title>
<description>descriptions</description>
<keywords />
</metadatas>
</record>
<record>
<metadatas>
<title>second title</title>
<description>descriptions 2</description>
<keywords>test, hello</keywords>
</metadatas>
</record>
</records>
出力
あなたはそれ自体、それはあなたが空のテキストを表示したい場合は、単に
textField
相対かなり良い答えにisBlankWhenNull="true"
を設定しますが、私の問題は、私が唯一持っているということです、値を持たないノードに対してnull
が表示されますれるように1つのレコードがその時に複数のレコードのラベルを作成したいのですが、現在のレコードにはキーワードがないので、フィールドは表示されません。 – Nicolasそれから手動で追加しますか?フィールドを追加するかjrxmlに直接入れる –
それは私がやることです、私はちょうどそこに他の方法があったと思っていた、 – Nicolas