cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

XSL if/when/otherwise Confusion

juliette.gibb1
1-Newbie

XSL if/when/otherwise Confusion

Hello Adepters,

I am modifying the References area to include a call out for a CASA reference summary. Basically all it does it take the contents from some <indxflags> and output it depending on the attribute contents (in this case it will be Regulatory References that is looks for). However, how do Iset it up to output the CASA References area only if the <indxflag> attributecontains the specific content (Regulatory References) in that particular data module?

So far it is calling out the one reference that I have inserted in the XML correctly but itappends that referenceacross all data modules not just the one that it is relevant too, this is because the first table within the refs template must always appear and I haven't included the if/when/otherwise statement around it to separate it. But that's because I'm not surewhere they actually need to go to make the whole thing work correctly.

The XML is marked up like this and I've attached a copy of the XSL that I'm working with:
<title>This is a title<indxflag ref1="Regulatory" references&quot;=" ref2="CASA" ref3="CAO"></title>

Any help would be greatly appreciated, thank you!

Cheers
Juliette


6 REPLIES 6

Hi Juliette,

Without really understanding the context it's hard to figure out exactly what's going on, but I'll take a stab:

Assuming that the "CASA References area" begins with the <fo:block ..=">CASA References</fo:block>, it looks like the problem might be that the shell of the reference area is always being output, even if the XML contains an indxflag[@ref1='Regulatory References']. To fix that, you could contain everything that consitutes the area inside of an <xsl:if> statement:

<xsl:if test="//indxflag[@ref1='Regulatory" references']&quot;=">

<fo:block>CASA....

</xsl:if>

Hope that helps,

-James




Hi Juliette-



There's not quite enough detail here for me to understand exactly what
you're aiming for here. If you can post a copy of the input and the
desired output, I'll have a better chance of helping you figure out the
right approach.



--Clay


Just curious, what is:

<xsl:when test="false()">


keith

On Feb 11, 2008 4:45 PM, Juliette Gibb <juliette.gibb@virginblue.com.au>
wrote:

> Hello Adepters,
>
> I am modifying the References area to include a call out for a CASA
> reference summary. Basically all it does it take the contents from some
> <indxflags> and output it depending on the attribute contents (in this case
> it will be Regulatory References that is looks for). However, how do I set
> it up to output the CASA References area only if the <indxflag>
> attribute contains the specific content (Regulatory References) in that
> particular data module?
>
> So far it is calling out the one reference that I have inserted in the XML
> correctly but it appends that reference across all data modules not just the
> one that it is relevant too, this is because the first table within the refs
> template must always appear and I haven't included the if/when/otherwise
> statement around it to separate it. But that's because I'm not sure where
> they actually need to go to make the whole thing work correctly.
>
> The XML is marked up like this and I've attached a copy of the XSL that
> I'm working with:
> <title>This is a title<indxflag ref1="Regulatory" references&quot;=" ref2="CASA"&lt;br"/>> ref3="CAO"></title>
>
> Any help would be greatly appreciated, thank you!
>
> Cheers
> Juliette
>
>

Hi Keith-



It's pretty much just what it sounds like, a choice condition that is
never followed. You might see this if someone is debugging a longish
<xsl:choose> tree and wants to make sure certain branches never get
followed (so they can focus on the remaining branches). I can't really
think of a reason why you'd leave it in a production stylesheet though.



--Clay


Makes sense, guess I never thought (or had the need) to do that.

As you can probably guess, I'm a bit rusty on my XSL, but while we're still
talking about it, what's the purpose of the ()'s around the att value?

test="@ref1=('Regulatory References')"

Yet another I haven't used.

That said, and knowing nothing about your XML spec...

"how do I set it up to output the CASA References area only if the
<indxflag> attribute contains the specific content (Regulatory References)
in that particular data module"

The only thing that seems suspect to me is that the XSL is doing:

<xsl:for-each select="//indxflag">

Perhaps this is an obvious point, but // will find all indxflag elements
from the root of the document, not within the current context. Also, it
might be necessary to wrap the table itself in something like
<xsl:if test=".//indxflag[@ref1='Regulatory" references']&quot;=">
So that it doesn't display when there are none within context. Again, I'm
not sure what your large XML document looks like, so the context itself
might be different.

keith

Hello,

Thanks everyone for your help. I think I'm getting closer with the help of your suggestions!

The stylesheet is still in development so its not a production version yet which is why I still have some of the weird false() statements in there and the extra brackets (). Basically I've just been testing everything I can think of to get it to work. I found a website that suggested the use of brackets was an option -it didn't actually made any difference though.

After a lot of fiddling around it is now actually nearly there. I had gone down too far with my if/when/otherwise statements and it was confusing itself. All I have to do now is to stop it inserting that reference into all modules rather than just the one it is relevant to.

Thank you all for your help.

Cheers
Juliette

Announcements