You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2022/04/05 13:25:00 UTC

[jira] [Commented] (NIFI-9831) XMLReader adds extra XML element to the schema if the input contains XML attribute

    [ https://issues.apache.org/jira/browse/NIFI-9831?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17517435#comment-17517435 ] 

ASF subversion and git services commented on NIFI-9831:
-------------------------------------------------------

Commit 3ef2ad99434461e603e7cd8b611906db05866568 in nifi's branch refs/heads/main from Peter Gyori
[ https://gitbox.apache.org/repos/asf?p=nifi.git;h=3ef2ad9943 ]

NIFI-9831: XML schema inference fix for XML elements with attributes

This closes #5895.

Signed-off-by: Peter Turcsanyi <tu...@apache.org>


> XMLReader adds extra XML element to the schema if the input contains XML attribute
> ----------------------------------------------------------------------------------
>
>                 Key: NIFI-9831
>                 URL: https://issues.apache.org/jira/browse/NIFI-9831
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Extensions
>            Reporter: Peter Gyori
>            Assignee: Peter Gyori
>            Priority: Major
>              Labels: inference, reader, schema, xml
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Let's use a ConvertRecord processor with an XMLReader to process XML documents. Let's set the reader's 'Schema Access Strategy' property to 'Infer Schema'. The processor can be configured with any writer, we just need to make sure the record schema is written in an attribute to the outgoing flowfile.
> XMLReader controller service settings:
>  * Schema Access Strategy: Infer Schema
>  * Expect Records as Array: false
> ConvertRecord processor settings:
>  * Record Reader: XMLReader
>  * Record Writer: any writer with _Schema Write Strategy: Set 'avro.schema' Attribute_ and _Schema Access Strategy: Inherit Record Schema_
> Input data:
> {code:java}
> <record>
>   <num>123</num>
>   <software favorite="true">Apache NiFi</software>
> </record>{code}
> Output schema:
> {code:java}
> {
>     "type": "record",
>     "name": "nifiRecord",
>     "namespace": "org.apache.nifi",
>     "fields": [
>         {
>             "name": "num",
>             "type": [
>                 "null",
>                 "int"
>             ]
>         },
>         {
>             "name": "software",
>             "type": [
>                 "null",
>                 {
>                     "type": "record",
>                     "name": "softwareType",
>                     "fields": [
>                         {
>                             "name": "favorite",
>                             "type": [
>                                 "null",
>                                 "boolean"
>                             ]
>                         },
>                         {
>                             "name": "value",
>                             "type": [
>                                 "null",
>                                 "string"
>                             ]
>                         }
>                     ]
>                 }
>             ]
>         },
>         {
>             "name": "favorite",
>             "type": [
>                 "null",
>                 "boolean"
>             ]
>         }
>     ]
> }{code}
> In the output schema the record/favorite element is unexpected.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)