Skip to main content

Hello Everyone, I have a field which contains table and column name together for Foreignkey using (,) and (#) seperators. I have created also List on this field already, now i am not understanding how I can make another list for getting those values.

Now my result XML is looking like :

bnr:table > element is getting all the table and column names now, but i want to see my XML as follows:

A partial coding of my XML template is as follows:

<bnr:MD_DataSchema>

 

{

 

let $n := xs:integer(fme:get-attribute("_element_count")) - 1

 

for $i in (0 to $n)

 

 

let $aname := "_list_name{"||$i||"}.Spalte"

 

let $atype := "_list_name{"||$i||"}.Datentyp"

 

let $descrip := "_list_name{"||$i||"}.Beschreibung"

 

let $fkey := "_list_name{"||$i||"}.Tabellenbeziehung"

 

let $mval := "_list_name{"||$i||"}.Fehlende_Werte"

 

 

return

 

{

 

if (not(fme:get-attribute($aname) eq "")) then

 

<bnr:column>

 

<bnr:MD_Column>

 

<bnr:tableName>

 

<gco:CharacterString>v140_mun.dbo.{fme:get-attribute("Tabelle")}</gco:CharacterString>

 

</bnr:tableName>

 

 

<bnr:name>

 

 

<gco:CharacterString>{fme:get-attribute($aname)}</gco:CharacterString>

 

</bnr:name>

 

{

 

if (not(fme:get-attribute($descrip) eq "")) then

 

<bnr:description>

 

<gco:CharacterString>{fme:get-attribute($descrip)}</gco:CharacterString>

 

 

</bnr:description>

 

else(<bnr:description>

 

<gco:CharacterString>No description</gco:CharacterString>

 

 

</bnr:description>

 

)

 

 

}

 

<bnr:dataType>

 

<gco:CharacterString>{fme:get-attribute($atype)}</gco:CharacterString>

 

</bnr:dataType>

 

{

 

if (not(fme:get-attribute($mval) eq "")) then

 

<bnr:missingValue>

 

<gco:CharacterString>{fme:get-attribute($mval)}</gco:CharacterString>

 

</bnr:missingValue>

 

else(<bnr:missingValue>

 

<gco:CharacterString>No Missing Value</gco:CharacterString>

 

</bnr:missingValue>

 

)

 

}

 

{

 

if (not(fme:get-attribute($fkey)eq "")) then

 

 

<bnr:foreignKey>

 

<bnr:MD_ForeignKey>

 

<bnr:identifier>

 

<gmd:MD_Identifier>

 

<gmd:code>

 

<gco:CharacterString></gco:CharacterString>

 

</gmd:code>

 

</gmd:MD_Identifier>

 

</bnr:identifier>

 

 

 

<bnr:table>

 

<gco:CharacterString>{fme:get-attribute($fkey)}</gco:CharacterString>

 

</bnr:table>

 

 

 

<bnr:column>

 

<gco:CharacterString></gco:CharacterString>

 

</bnr:column>

 

</bnr:MD_ForeignKey>

 

</bnr:foreignKey>

 

else ()

 

}

 

</bnr:MD_Column>

 

</bnr:column>

 

 

else ()

 

}

 

}
@takashi

 

 


Hi @mjoarder_pln, you can use the XQuery "fn:tokenize" function to split a string. For example, the partial expression that creates <bnr:foreignKey> elements can be replaced with this expression. Note: <bnr:foreignKey> elements would not be created if fme:get-attribute($fkey) was empty.

{
    for $k in fn:tokenize(fme:get-attribute($fkey), '#')
    let $s := fn:tokenize($k, ',')
    return
    <bnr:foreignKey>
        <bnr:MD_ForeignKey>
            <bnr:identifier>
                <gmd:MD_Identifier>
                    <gmd:code>
                        <gco:CharacterString></gco:CharacterString>
                    </gmd:code>
                </gmd:MD_Identifier>
            </bnr:identifier>
            <bnr:table>
                <gco:CharacterString>{$sÂ1]}</gco:CharacterString>
            </bnr:table>
            <bnr:column>
                <gco:CharacterString>{$sÂ2]}</gco:CharacterString>
            </bnr:column>
        </bnr:MD_ForeignKey>
    </bnr:foreignKey>
}

Hope this helps.


Hi @mjoarder_pln, you can use the XQuery "fn:tokenize" function to split a string. For example, the partial expression that creates <bnr:foreignKey> elements can be replaced with this expression. Note: <bnr:foreignKey> elements would not be created if fme:get-attribute($fkey) was empty.

{
    for $k in fn:tokenize(fme:get-attribute($fkey), '#')
    let $s := fn:tokenize($k, ',')
    return
    <bnr:foreignKey>
        <bnr:MD_ForeignKey>
            <bnr:identifier>
                <gmd:MD_Identifier>
                    <gmd:code>
                        <gco:CharacterString></gco:CharacterString>
                    </gmd:code>
                </gmd:MD_Identifier>
            </bnr:identifier>
            <bnr:table>
                <gco:CharacterString>{$sÂ1]}</gco:CharacterString>
            </bnr:table>
            <bnr:column>
                <gco:CharacterString>{$sÂ2]}</gco:CharacterString>
            </bnr:column>
        </bnr:MD_ForeignKey>
    </bnr:foreignKey>
}

Hope this helps.

Hi , Takashi, it works ! great, thanks a lot !

 

 

 


Reply