For a Google Shopping feed I need to give Google some variables of products I have.
Case: There are 3 Unique Product Identifiers:
<!-- Unique Product Identifiers-->
<g:brand>{manufacturer}</g:brand>
<g:gtin>{upc}</g:gtin>
<g:mpn>{sku}</g:mpn>
And one way to say if it's true or false:
<g:identifier_exists>TRUE</g:identifier_exists>
The g:identifier_exists should be true of 1 of the 3 identifiers is filled in (not null/empty). If all 3 are empty then the identifier should be FALSE. Like this:
<g:identifier_exists>FALSE</g:identifier_exists>
Is this possible with XML?
EDIT: Someone mentioned XLST so I tried the following:
<item>
!-- Basic Product Information -->
<g:id>{sku}</g:id>
<title>{name,[substr],[70],[...]}</title>
<description>{description,[html_entity_decode],[strip_tags]}</description>
{G:GOOGLE_PRODUCT_CATEGORY}
{G:PRODUCT_TYPE,[10]}
<link>{url parent}</link>
{G:IMAGE_LINK}
<g:condition>new</g:condition>
<!-- Availability & Price -->
<g:availability>{is_in_stock?[in stock]:[out of stock]:[available for order]}</g:availability>
<g:price>{normal_price,[USD],[0]}USD</g:price>
{G:SALE_PRICE,[USD],[0]}
<!-- Unique Product Identifiers-->
<xsl:choose>
<xsl:when test=" g:brand != ''' ">
<g:identifier_exists>TRUE</g:identifier_exists>
</xsl:when>
<xsl:when test=" g:gtin != ''' ">
<g:identifier_exists>TRUE</g:identifier_exists>
</xsl:when>
<xsl:when test=" g:mpn != ''' ">
<g:identifier_exists>TRUE</g:identifier_exists>
</xsl:when>
<xsl:otherwise>
<g:identifier_exists>FALSE</g:identifier_exists>
</xsl:otherwise>
</xsl:choose>
<!-- Apparel Products -->
<g:gender>{gender}</g:gender>
<g:age_group>{age_group}</g:age_group>
<g:color>{color}</g:color>
<g:size>{size}</g:size>
<!-- Product Variants -->
{G:ITEM_GROUP_ID}
<g:material>{material}</g:material>
<g:pattern>{pattern}</g:pattern>
<!-- Shipping -->
<g:shipping_weight>{weight,[float],[2]}kg</g:shipping_weight>
<!-- AdWords attributes -->
<g:adwords_grouping>{adwords_grouping}</g:adwords_grouping>
<g:adwords_labels>{adwords_labels}</g:adwords_labels>
</item>
I am going to answer this somewhat indirectly since I don't know much about your environment. This may not even match your requirement. First some background information that I base this upon:
Notes on supported formats the XML is in there, there are two, RSS and ATOM. https://support.google.com/merchants/answer/160567?hl=en&ref_topic=3163841
That is our target, say for example we choose an RSS formatted XML file as our "feed" that is needed in the form specified in that link. Now to do that we need to execute an XSLT transform from our source, whatever that is into that RSS specified format.
This XSLT file can then detect what you need (you have a start there). XSLT is the "program" part, the XML is the source part. NOTE: The "1 of 3" seems to be "2 of 3" from the links/info I see on the link I provided AND in the example feed from there. There are some other questions regarding XSL conditionals etc such as Conditional test around xsl:apply-templates Search around a bit.
Here is a simple work flow example:
XML Input ==> process with XSLT ==> produced XML feed
Here we can leverage the power of StackOverflow! Here is a question with some XML and XSLT you might start from: How can I use XSLT to create an RSS 2.0 feed from an XML file?
Think of the "template" and match as a part to use for each element.
Here is an example RSS XML document sample output from the page I linked above: http://commondatastorage.googleapis.com/newfeedspec/example_feed_xml_rss.xml.zip
Here is a link where someone wants to USE the RSS to create a new form of XML: XSLT Transformation of Google product feed xml