Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

How to get Query Multiple to return standard XML

Avatar

Level 2

Hi,

I'm looking for a way to get the Query Multipe to return the XML with the correct XML standard convention for nulls from the datastore.

Query Multiple currently returns:

<FacilityList>
    <Facility>
        <Id>1111</Id>
        <Name>Auto Fac Name 2 20100901</Name>
        <Alias>AFN</Alias>
        <PhysicalAssetBusinessNumber/> <--blank in database.  XML fine.

        <PhoneNumber>null</PhoneNumber> <--null in database but this is wrong for XML

    </Facility>

</FacilityList>

Should be:

<FacilityList>
     <Facility>
         <Id>1111</Id>
         <Name>Auto Fac Name 2 20100901</Name>
         <Alias>AFN</Alias>
         <PhysicalAssetBusinessNumber/>

         </PhoneNumber xsi:nil="true">

    </Facility>

</FacilityList>

Any suggestions or explanations as to why this is the case?

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

In the case of MySQL, if the column allows nulls and the value is null, the XML result set will include 'null'. It probably varies by database and JDBC driver.

You will have to use XSLT to manage the transformation to xsi:nil="true".

Steve

View solution in original post

2 Replies

Avatar

Correct answer by
Former Community Member

In the case of MySQL, if the column allows nulls and the value is null, the XML result set will include 'null'. It probably varies by database and JDBC driver.

You will have to use XSLT to manage the transformation to xsi:nil="true".

Steve

Avatar

Level 2

Hi,

Okay that's what I thought.  What I don't understand is why.  The standard is pretty clear.  What's the reasoning behind not returning nulls correctly represented?

Also, do you have an XSLT example somewhere handy?

Thanks!

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----