L
Lord0
Hi there,
Is the following possible with XSLT? Given the following example XML
docs:
<!-- doc 1-->
<user>
<username>myUsername</username>
<password></password>
<phone>12345</phone>
</user>
<!-- doc2 -->
<user>
<title>Mr</title>
<username>myUsername</username>
<password></password>
<phone>12345</phone>
<address>some st</address>
</user>
transform doc 1 into
<user>
<username>myUsername</username>
<password>PASSWORD MISSING</password>
<phone>12345</phone>
</user>
transform doc 2 into
<user>
<title>Mr</title>
<username>myUsername</username>
<password>PASSWORD MISSING</password>
<phone>12345</phone>
<address>some st</address>
</user>
So what I want to do is modify some elements but reproduce others "as
is". I do not know what the input elements may be but I do know that
the XPath for the elements to be modified/tested will not change. I am
thinking of XSLT, pseudo, like:
<xsl:template match="/">
<xsl:for-each select="/">
<xsl:choose>
<xsl:when test="/user/password is empty">
<password>PASSWORD MISSING</password>
</xsl:when>
<xsltherwise>
<!-- this is the bit I'm not sure about -->
just output the element and value as is
</xsltherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
Am I mad?
Cheers
Lord0
Is the following possible with XSLT? Given the following example XML
docs:
<!-- doc 1-->
<user>
<username>myUsername</username>
<password></password>
<phone>12345</phone>
</user>
<!-- doc2 -->
<user>
<title>Mr</title>
<username>myUsername</username>
<password></password>
<phone>12345</phone>
<address>some st</address>
</user>
transform doc 1 into
<user>
<username>myUsername</username>
<password>PASSWORD MISSING</password>
<phone>12345</phone>
</user>
transform doc 2 into
<user>
<title>Mr</title>
<username>myUsername</username>
<password>PASSWORD MISSING</password>
<phone>12345</phone>
<address>some st</address>
</user>
So what I want to do is modify some elements but reproduce others "as
is". I do not know what the input elements may be but I do know that
the XPath for the elements to be modified/tested will not change. I am
thinking of XSLT, pseudo, like:
<xsl:template match="/">
<xsl:for-each select="/">
<xsl:choose>
<xsl:when test="/user/password is empty">
<password>PASSWORD MISSING</password>
</xsl:when>
<xsltherwise>
<!-- this is the bit I'm not sure about -->
just output the element and value as is
</xsltherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
Am I mad?
Cheers
Lord0