Re: [xsl] xsl:for-each in Corresp Tag

Subject: Re: [xsl] xsl:for-each in Corresp Tag
From: "Dimitre Novatchev dnovatchev@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 12 Feb 2020 17:33:00 -0000
Can't the XML  /  XSLT  be properly indented? Absolutely unreadable!

On Wed, Feb 12, 2020 at 9:05 AM Byomokesh Sahoo sahoo.byomokesh@xxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> Hi,
>
> I am facing difficulty to get required output in different structure of
> <corres>. Find the below three types of tagging structure.
>
> Not getting exact output if apply <xsl:for-each> on below three type of
> scenario.
>
> XML
>
> <corresp><label>Correspondence to</label> Anne Marie Darling, <institution
> content-type="department">Department of Epidemiology</institution>,
> <institution>Boston University</institution>, <addr-line
> content-type="street">715 Albany Street</addr-line>,
> <country>USA</country>; <email>amdarlin@xxxxxx</email></corresp>
>
> <corresp><label>Correspondence to</label> Anne Marie Darling, <institution
> content-type="department">Department of Epidemiology</institution>,
> <addr-line content-type="postal-code">02118</addr-line>,
> <country>USA</country>; </corresp>
>
> <corresp>Joanne Lawrence, Association of British Neurologists, Ormond
> House, 27 Boswell Street, London WC1N 3JZ, UK; <email>
> joanne.lawrence@xxxxxxxxxx</email></corresp>
>
> My XSLT
> <xsl:template match="corresp">
> <xsl:element name="corresp">
> <xsl:for-each select="label">
> <xsl:element name="x">
> <xsl:value-of select="."/>
> </xsl:element>
> <xsl:text>, </xsl:text>
> </xsl:for-each>
> <institution>
> <xsl:for-each select="institution">
> <xsl:choose>
> <xsl:when test="@content-type='department'">
>
> <xsl:element name="department">
> <xsl:apply-templates select="node()" mode="copy-no-namespaces"/>
> </xsl:element>
> <xsl:text>, </xsl:text>
> </xsl:when>
> <xsl:otherwise>
> <xsl:element name="institution-name">
> <xsl:value-of select="."/>
> </xsl:element>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:for-each>
> </institution>
> <xsl:text>, </xsl:text>
>
> <xsl:for-each select="addr-line">
> <xsl:choose>
> <xsl:when test="@content-type='street'">
> <xsl:element name="street">
> <xsl:value-of select="."/>
> </xsl:element>
> <xsl:text>, </xsl:text>
> </xsl:when>
> <xsl:when test="@content-type='postal-code'">
> <xsl:element name="postal-code">
> <xsl:value-of select="."/>
> </xsl:element>
> <xsl:text>, </xsl:text>
> </xsl:when>
> </xsl:choose>
> </xsl:for-each>
> <xsl:for-each select="country">
> <xsl:element name="country">
> <xsl:value-of select="."/>
> </xsl:element>
> <xsl:text>; </xsl:text>
> </xsl:for-each>
> <xsl:for-each select="email">
> <xsl:element name="email">
> <xsl:value-of select="."/>
> </xsl:element>
> </xsl:for-each>
> </xsl:element>
> </xsl:template>
>
> Desired Output
>
> <corresp><x>Correspondence to</x> Anne Marie Darling,
> <institution><department>Department of Epidemiology</department>,
> <institution-name>Boston University</institution-name></institution>,
> <street>715 Albany Street</street>, <country>USA</country>; <email>
> amdarlin@xxxxxx</email></corresp>
>
> <corresp><x>Correspondence to</x> Anne Marie Darling,
> <institution><department>Department of Epidemiology</department>,
> <postal-code>02118</postal-code>, <country>USA</country>; <email>
> amdarlin@xxxxxx</email></corresp>
>
> <corresp>Joanne Lawrence, Association of British Neurologists, Ormond
> House, 27 Boswell Street, London WC1N 3JZ, UK; <email>
> joanne.lawrence@xxxxxxxxxx</email></corresp>
>
> Kindly suggest.
>
> thanks
> byomokesh
>
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/782854> (by
> email <>)
>


-- 
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
To achieve the impossible dream, try going to sleep.
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they write
all patents, too? :)
-------------------------------------
Sanity is madness put to good use.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.

Current Thread