Subject: Re: How to Handle Attributes Content
From: Imrran Wahid <devguy2003@xxxxxxxxx>
Date: Thu, 20 Feb 2003 05:24:18 -0800 (PST)
|
I realised that I had typographical errors when
composing this message. So here is the corrected
templates I am using.
<xsl:template match="//Content" mode="raw">
<xsl:copy>
<xsl:text><</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>></xsl:text>
<xsl:value-of select="text()"/>
<xsl:apply-templates select="*|@*"
mode="raw-req-inner"/>
<br/>
<xsl:text></</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>></xsl:text>
</xsl:copy>
</pre>
</xsl:template>
<xsl:template match="Content//*" mode="raw-req-inner">
<xsl:copy>
<br/>
<xsl:for-each select="ancestor::*[name()
='SomeInput']">
<xsl:value-of select="$str-indent" />
</xsl:for-each>
<xsl:text><</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>></xsl:text>
<xsl:value-of select="text()"/>
<xsl:apply-templates select="*|@*"
mode="raw-req-inner"/>
<xsl:if test="count(./*) > 0">
<br/>
<xsl:for-each
select="ancestor::*[name()!='SomeInput']">
<xsl:value-of select="$str-indent" />
</xsl:for-each>
</xsl:if>
<xsl:text></</xsl:text>
<xsl:value-of select="name()"/>
<xsl:text>></xsl:text>
</xsl:copy>
</xsl:template>
>
> The challenge at hand is that my xml can also be in
> attributes. How do I render the raw xml with
> attributes and proper indentations? For instance my
> xml is:
>
> <SomeInput>
> <Content
> CodeI="2"
> ID="6">
> <Trans>
> <Tran TranNum="1" TranAmt="10.00"/>
> <Tran TranNum="2" TranAmt="12.00"/>
> </Trans>
> </Content>
> </SomeInput>
>
> Also if there were no Trans elements then the raw
> xml
> should be rendered as:
>
> <SomeInput>
> <Content
> CodeI="2"
> ID="6"/>
> </SomeInput>
>
> The Content element could have an undetermined
> number
> of attributes.
>
Sorry about the mixup
Imrran
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|