
|
A tricky xref problem
Hi all,
I wonder if there is a way to extract a text string and pass it as a value for the <xref linkend=""/> expression. For example, when I write:
Some text text text (see ref=[sect_test]),
I would like to take the text within the [ ] delimiters and pass it as a value for the linkend attribute of the xref element called in my customized table template. The reason for this special workaround is that I've created a custom template that enables you to add a table row with its entries using one command, like so: <table> ...
<row entry1="red" entry2="blue" entry3="black"/> -which saves a lot of typing.
So, if I wish to add a reference to some section from within entry1, I can't write: <row entry1="red (refer to <xref linkend="sect_test"/>)" entry2="blue"
entry3="black"/>
I need somehow to customize my table template that says something like: ... <xsl:for-each select="row"> <row> <xsl:if test="$entry1"> <entry> <xsl:value-of select="@entry1"/> <xsl:if test="contains('xref')"> <xref> <xsl:copy-of select="@*"/> <xsl:attribute name="linkend"> <xsl:copy-of select="@*"/> <xsl:value-of
select="<extracted_text_string>"/> </xsl:attribute> </xref> </xsl:if> </entry> </xsl:if> ... </row> </xsl:for-each> ...
Please, advise me how to extract the text string from within [ ] delimiters to pass it as a value for the <xref> expression.
Thanks a lot in advance!!!
Best wishes, Nancy
|
|

|
RE: A tricky xref problem
Your example is confusing, because in standard DocBook,
<row> does not have "entry" attributes, only <entry> child
elements.
But assuming you know that and this is really what you
want, it sounds like you are saying that you want to use the concatenated values
of the other attributes as the link ID. I think that you would do that not by
dynamically adding a "linkend" attribute, but by modifying the "xref" template
so that it retrieves the values of those other attributes
directly; something like this:
<xsl:variable name="linkID" select="@linkend"
/>
<xsl:choose>
<xsl:when test="id( $linkID
)">
<xsl:call-template name="createURI">
<xsl:with-param name="element" select="id( $linkID )"
/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="createURI">
<xsl:with-param name="element" select="*[concat(@entry1, @entry2, @entry3) =
$linkID]" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
You would have to make the entry text
retrieval match the exact pattern you want, but that's generally how I'd
approach it.
Hi all,
I wonder if there is a way to extract a
text string and pass it as a value for the <xref linkend=""/>
expression. For example, when I write:
Some text
text text (see ref=[sect_test]),
I would like
to take the text within the [ ] delimiters and pass it as a value for
the linkend attribute of the xref element called in my customized table
template. The reason for this special workaround is that I've
created a custom template that enables you to add a table row with its
entries using one command, like
so: <table> ...
<row entry1="red" entry2="blue"
entry3="black"/> -which saves a lot of typing.
So, if I wish
to add a reference to some section from within entry1, I can't
write: <row entry1="red (refer to <xref
linkend="sect_test"/>)" entry2="blue" entry3="black"/>
I
need somehow to customize my table template that says something
like: ... <xsl:for-each select="row">
<row> <xsl:if
test="$entry1">
<entry> <xsl:value-of
select="@entry1"/> <xsl:if
test="contains('xref')">
<xref>
<xsl:copy-of
select="@*"/>
<xsl:attribute
name="linkend">
<xsl:copy-of
select="@*"/>
<xsl:value-of
select="<extracted_text_string>"/>
</xsl:attribute>
</xref>
</xsl:if>
</entry>
</xsl:if> ... </row> </xsl:for-each> ...
Please,
advise me how to extract the text string from within [ ] delimiters to
pass it as a value for the <xref> expression.
Thanks a lot
in advance!!!
Best
wishes, Nancy
|
|

|
Re: RE: A tricky xref problem
Hi Rob,
First of all, thanks a lot for your quick response!
I think you misunderstood me, and it's my fault. I'll try to provide more details about my "design":
what i tried to do is to minimize the amount of tags you need to type in, to create a table.
So, I defined a kind of a macro, that builds the table's look and feel, headings, etc.
<xsl:template match="jstatuscodestable"> <xsl:variable name="e1"> <xsl:apply-templates/> </xsl:variable> <xsl:variable name="e2"> <xsl:apply-templates/> </xsl:variable>
<xsl:element name="table"> <xsl:attribute name="frame"> <xsl:value-of select="'all'"/> </xsl:attribute> <xsl:attribute name="id"> <xsl:value-of
select="@id"/> </xsl:attribute> <title><xsl:value-of select="@t"/></title> <tgroup cols="2"> <colspec colnum="1" colname="col1" colwidth="*"/> <colspec colnum="2" colname="col2" colwidth="1.5*"/> <thead> <row> ... </row> </thead> <tbody> <xsl:for-each select="row"> <row> <xsl:if test="$e1"> <entry> <xsl:value-of select="@e1"/> <xsl:if test="contains('xref')"> <xref>
<xsl:copy-of select="@*"/> <xsl:attribute name="linkend"> <xsl:copy-of select="@*"/> <xsl:value-of select="<extracted_text>"/> </xsl:attribute> </xref> </xsl:if>-->
</entry> </xsl:if>
<xsl:if test="$e2">
<entry> <xsl:value-of select="@e2"/> </entry> </xsl:if> </row> </xsl:otherwise> </xsl:choose> </xsl:for-each> </tbody> </tgroup> </xsl:element> </xsl:template>
So, to add such a table, I only need to enter: <jstatuscodestable> <row e1="blue" e2="red"> <row e1="black" e2="yellow"> ... </jstatuscodestable>
instead of entering dozens of table elements each time.
But then, I discovered that I can't add an <xref> within an entry. I can't
write: <row e1="blue (refer to <xref
linkend="sect_test"/>)" e2="red"/>
So I wonder, if somehow a piece of text within e1's value (e.x. sect_test) can be extracted and passed as a value for linkend I added (as an example) in the first <entry> tag in the template above. Of course, I would like to be able to add an xref in any entry within the table.
I hope this time, my explanation is clearer :-)
Thanks a lot in advance!
Best wishes, Nancy
--- On Tue, 10/20/09, Cavicchio_Rob@... <Cavicchio_Rob@...> wrote:
From: Cavicchio_Rob@... <Cavicchio_Rob@...> Subject: [docbook-apps] RE: A tricky xref problem To: nancy_brndt@..., docbook-apps@... Cc: bobs@... Date: Tuesday, October 20, 2009, 8:20 AM
Your example is confusing, because in standard DocBook,
<row> does not have "entry" attributes, only <entry> child
elements.
But assuming you know that and this is really what you
want, it sounds like you are saying that you want to use the concatenated values
of the other attributes as the link ID. I think that you would do that not by
dynamically adding a "linkend" attribute, but by modifying the "xref" template
so that it retrieves the values of those other attributes
directly; something like this:
<xsl:variable name="linkID" select="@linkend"
/>
<xsl:choose>
<xsl:when test="id( $linkID
)">
<xsl:call-template name="createURI">
<xsl:with-param name="element" select="id( $linkID )"
/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="createURI">
<xsl:with-param name="element" select="*[concat(@entry1, @entry2, @entry3) =
$linkID]" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
You would have to make the entry text
retrieval match the exact pattern you want, but that's generally how I'd
approach it.
Hi all,
I wonder if there is a way to extract a
text string and pass it as a value for the <xref linkend=""/>
expression. For example, when I write:
Some text
text text (see ref=[sect_test]),
I would like
to take the text within the [ ] delimiters and pass it as a value for
the linkend attribute of the xref element called in my customized table
template. The reason for this special workaround is that I've
created a custom template that enables you to add a table row with its
entries using one command, like
so: <table> ...
<row entry1="red" entry2="blue"
entry3="black"/> -which saves a lot of typing.
So, if I wish
to add a reference to some section from within entry1, I can't
write: <row entry1="red (refer to <xref
linkend="sect_test"/>)" entry2="blue" entry3="black"/>
I
need somehow to customize my table template that says something
like: ... <xsl:for-each select="row">
<row> <xsl:if
test="$entry1">
<entry> <xsl:value-of
select="@entry1"/> <xsl:if
test="contains('xref')">
<xref>
<xsl:copy-of
select="@*"/>
<xsl:attribute
name="linkend">
<xsl:copy-of
select="@*"/>
<xsl:value-of
select="<extracted_text_string>"/>
</xsl:attribute>
</xref>
</xsl:if>
</entry>
</xsl:if> ... </row> </xsl:for-each> ...
Please,
advise me how to extract the text string from within [ ] delimiters to
pass it as a value for the <xref> expression.
Thanks a lot
in advance!!!
Best
wishes, Nancy
|
|
|

|
RE: RE: A tricky xref problem
I think I understand now. You are transforming *into*
DocBook, and you want each entry's attribute value to include not only the text
for the entry, but the value of the "linkend" attribute that will go into the
DocBook output.
You could certainly perform text string manipulations
so that if the "linkend" value were written in a predictable way, you could
extract its value. For example, if your source document had
this:
<row
e1="blue_sectionID">
then your transform could do this:
<entry>
<xsl:value-of select="substring-before( @e1, '_' )" />
<xsl:if
test="string-length( substring-after(@e1, '_') )">
<xref>
<xsl:attribute name="linkend" />
<xsl:value-of select="substring-after( @e1, '_' )"
/>
</xsl:attribute>
</xref>
</xsl:if>
</entry>
which should produce this:
<entry>
blue
<xref
linkend="sectionID" />
</entry>
You could also use a separate source
attribute for the "linkend" attribute value; for example:
<row e1="blue" e1link="sectionID"
/>
That would achieve the same effect, but avoids having
to do all the string manipulations, and also avoids having to designate a
special character that you then can't easily use in the actual
content.
Hi Rob,
First of all, thanks a lot for your quick
response!
I think you misunderstood me, and it's my fault. I'll
try to provide more details about my "design":
what i tried to do
is to minimize the amount of tags you need to type in, to create a
table.
So, I defined a kind of a macro, that builds the table's
look and feel, headings, etc.
<xsl:template
match="jstatuscodestable"> <xsl:variable
name="e1">
<xsl:apply-templates/> </xsl:variable> <xsl:variable
name="e2">
<xsl:apply-templates/> </xsl:variable>
<xsl:element
name="table"> <xsl:attribute name="frame">
<xsl:value-of
select="'all'"/> </xsl:attribute> <xsl:attribute
name="id"> <xsl:value-of
select="@id"/> </xsl:attribute> <title><xsl:value-of
select="@t"/></title> <tgroup cols="2"> <colspec
colnum="1" colname="col1" colwidth="*"/> <colspec colnum="2"
colname="col2" colwidth="1.5*"/> <thead>
<row> ...
</row> </thead> <tbody> <xsl:for-each
select="row">
<row> <xsl:if
test="$e1">
<entry>
<xsl:value-of
select="@e1"/>
<xsl:if
test="contains('xref')">
<xref>
<xsl:copy-of
select="@*"/>
<xsl:attribute name="linkend">
<xsl:copy-of
select="@*"/>
<xsl:value-of
select="<extracted_text>"/>
</xsl:attribute>
</xref>
</xsl:if>-->
</entry>
</xsl:if>
<xsl:if
test="$e2">
<entry>
<xsl:value-of
select="@e2"/>
</entry>
</xsl:if>
</row> </xsl:otherwise>
</xsl:choose>
</xsl:for-each> </tbody> </tgroup> </xsl:element> </xsl:template>
So,
to add such a table, I only need to
enter: <jstatuscodestable> <row e1="blue"
e2="red"> <row e1="black" e2="yellow">
... </jstatuscodestable>
instead of entering dozens of
table elements each time.
But then, I discovered that I can't add
an <xref> within an entry. I can't write: <row e1="blue
(refer to <xref linkend="sect_test"/>)" e2="red"/>
So I
wonder, if somehow a piece of text within e1's value (e.x. sect_test)
can be extracted and passed as a value for linkend I added (as an
example) in the first <entry> tag in the template above. Of
course, I would like to be able to add an xref in any entry within the
table.
I hope this time, my explanation is clearer
:-)
Thanks a lot in advance!
Best
wishes, Nancy
--- On Tue, 10/20/09, Cavicchio_Rob@...
<Cavicchio_Rob@...> wrote:
From:
Cavicchio_Rob@... <Cavicchio_Rob@...> Subject:
[docbook-apps] RE: A tricky xref problem To: nancy_brndt@...,
docbook-apps@... Cc: bobs@... Date:
Tuesday, October 20, 2009, 8:20 AM
Your example is confusing, because in
standard DocBook, <row> does not have "entry" attributes, only
<entry> child elements.
But assuming you know that and this is really
what you want, it sounds like you are saying that you want to use the
concatenated values of the other attributes as the link ID. I think
that you would do that not by dynamically adding a "linkend"
attribute, but by modifying the "xref" template so that it retrieves
the values of those other attributes directly; something like
this:
<xsl:variable name="linkID"
select="@linkend" />
<xsl:choose>
<xsl:when test="id(
$linkID )">
<xsl:call-template name="createURI">
<xsl:with-param name="element" select="id( $linkID )"
/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="createURI">
<xsl:with-param name="element" select="*[concat(@entry1, @entry2,
@entry3) = $linkID]" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
You would have to make the entry text
retrieval match the exact pattern you want, but that's generally
how I'd approach it.
Hi all,
I wonder if there is a way to
extract a text string and pass it as a value for the <xref
linkend=""/> expression. For example, when I
write:
Some text text text (see
ref=[sect_test]),
I would like to take the text within
the [ ] delimiters and pass it as a value for the linkend
attribute of the xref element called in my customized table
template. The reason for this special workaround is that
I've created a custom template that enables you to add a table
row with its entries using one command, like
so: <table> ...
<row entry1="red"
entry2="blue" entry3="black"/> -which saves a lot of
typing.
So, if I wish to add a reference to some
section from within entry1, I can't write: <row
entry1="red (refer to <xref linkend="sect_test"/>)"
entry2="blue" entry3="black"/>
I need somehow to
customize my table template that says something
like: ... <xsl:for-each select="row">
<row> <xsl:if
test="$entry1">
<entry>
<xsl:value-of
select="@entry1"/>
<xsl:if
test="contains('xref')">
<xref>
<xsl:copy-of
select="@*"/>
<xsl:attribute
name="linkend">
<xsl:copy-of
select="@*"/>
<xsl:value-of
select="<extracted_text_string>"/>
</xsl:attribute>
</xref>
</xsl:if>
</entry>
</xsl:if> ... </row> </xsl:for-each> ...
Please,
advise me how to extract the text string from within [ ]
delimiters to pass it as a value for the <xref>
expression.
Thanks a lot in advance!!!
Best
wishes, Nancy
|
|
|

|
RE: RE: A tricky xref problem
Hi Rob,
Thanks a lot for your suggestions! The second option you describe could be ideal, if we could somehow associate between the 'e1' and 'e1link' attributes, so that the value of 'sectionID' could go to the xref in the desired table entry (in this case, entry1). Is it possible? Otherwise, how does the compiler know where to send sectionID - xref of entry1 or entry 2?
Thank you a lot again!!!
My best wishes,
From: Cavicchio_Rob@... <Cavicchio_Rob@...> Subject: RE: [docbook-apps] RE: A tricky xref problem To: nancy_brndt@..., docbook-apps@... Cc: bobs@... Date: Tuesday, October 20, 2009, 9:38 AM
I think I understand now. You are transforming *into* DocBook, and you want each entry's attribute value to include not only the text for the entry, but the value of the "linkend" attribute that will go into the DocBook output.
You could certainly perform text string manipulations so that if the "linkend" value were written in a predictable way, you could extract its value. For example, if your source document had this:
<row e1="blue_sectionID">
then your transform could do this:
<entry>
<xsl:value-of select="substring-before( @e1, '_' )" />
<xsl:if test="string-length( substring-after(@e1, '_') )">
<xref>
<xsl:attribute name="linkend" />
<xsl:value-of select="substring-after( @e1, '_' )" /> </xsl:attribute>
</xref>
</xsl:if>
</entry>
which should produce this:
<entry>
blue
<xref linkend="sectionID" />
</entry>
You could also use a separate source attribute for the "linkend" attribute value; for example:
<row e1="blue" e1link="sectionID" />
That would achieve the same effect, but avoids having to do all the string manipulations, and also avoids having to designate a special character that you then can't easily use in the actual content.
Hi Rob,
First of all, thanks a lot for your quick response!
I think you misunderstood me, and it's my fault. I'll try to provide more details about my "design":
what i tried to do is to minimize the amount of tags you need to type in, to create a table.
So, I defined a kind of a macro, that builds the table's look and feel, headings, etc.
<xsl:template match="jstatuscodestable"> <xsl:variable name="e1"> <xsl:apply-templates/> </xsl:variable> <xsl:variable name="e2"> <xsl:apply-templates/> </xsl:variable>
<xsl:element name="table"> <xsl:attribute name="frame"> <xsl:value-of select="'all'"/> </xsl:attribute> <xsl:attribute name="id"> <xsl:value-of select="@id"/> </xsl:attribute> <title><xsl:value-of select="@t"/></title> <tgroup
cols="2"> <colspec colnum="1" colname="col1" colwidth="*"/> <colspec colnum="2" colname="col2" colwidth="1.5*"/> <thead> <row> ... </row> </thead> <tbody> <xsl:for-each select="row"> <row> <xsl:if test="$e1"> <entry> <xsl:value-of select="@e1"/> <xsl:if test="contains('xref')"> <xref> <xsl:copy-of select="@*"/>
<xsl:attribute name="linkend"> <xsl:copy-of select="@*"/> <xsl:value-of select="<extracted_text>"/> </xsl:attribute> </xref> </xsl:if>-->
</entry> </xsl:if>
<xsl:if test="$e2"> <entry> <xsl:value-of select="@e2"/>
</entry> </xsl:if> </row> </xsl:otherwise> </xsl:choose> </xsl:for-each> </tbody> </tgroup> </xsl:element> </xsl:template>
So, to add such a table, I only need to enter: <jstatuscodestable> <row e1="blue" e2="red"> <row e1="black" e2="yellow"> ... </jstatuscodestable>
instead of entering dozens of table elements each time.
But then, I discovered that I can't add an <xref> within an entry. I can't write: <row e1="blue (refer to <xref linkend="sect_test"/>)" e2="red"/>
So I wonder, if somehow a piece of text within e1's value (e.x. sect_test) can be extracted and passed as a value for linkend I added (as an example) in the first <entry> tag in the
template above. Of course, I would like to be able to add an xref in any entry within the table.
I hope this time, my explanation is clearer :-)
Thanks a lot in advance!
Best wishes, Nancy
--- On Tue, 10/20/09, Cavicchio_Rob@... <Cavicchio_Rob@...> wrote:
From: Cavicchio_Rob@... <Cavicchio_Rob@...> Subject: [docbook-apps] RE: A tricky xref problem To: nancy_brndt@..., docbook-apps@... Cc: bobs@... Date: Tuesday, October 20, 2009, 8:20 AM
Your example is confusing, because in standard DocBook, <row> does not have "entry" attributes, only <entry> child elements.
But assuming you know that and this is really what you want, it sounds like you are saying that you want to use the concatenated values of the other attributes as the link ID. I think that you would do that not by dynamically adding a "linkend" attribute, but by modifying the "xref" template so that it retrieves the values of those other attributes directly; something like this:
<xsl:variable name="linkID" select="@linkend" />
<xsl:choose>
<xsl:when test="id( $linkID )">
<xsl:call-template name="createURI">
<xsl:with-param name="element" select="id( $linkID )" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="createURI">
<xsl:with-param name="element" select="*[concat(@entry1, @entry2, @entry3) = $linkID]" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
You would have to make the entry text retrieval match the exact pattern you want, but that's generally how I'd approach it.
Hi all,
I wonder if there is a way to extract a text string and pass it as a value for the <xref linkend=""/> expression. For example, when I write:
Some text text text (see ref=[sect_test]),
I would like to take the text within the [ ] delimiters and pass it as a value for the linkend attribute of the xref element called in my customized table template. The reason for this special workaround is that I've created a custom template that enables you to add a table row with its entries using one command, like so: <table> ...
<row entry1="red" entry2="blue" entry3="black"/> -which saves a lot of typing.
So, if I wish to add a reference to some section from within entry1, I can't write: <row entry1="red (refer to <xref linkend="sect_test"/>)" entry2="blue" entry3="black"/>
I need somehow to customize my table template that says
something like: ... <xsl:for-each select="row"> <row> <xsl:if test="$entry1"> <entry> <xsl:value-of select="@entry1"/> <xsl:if test="contains('xref')"> <xref> <xsl:copy-of select="@*"/> <xsl:attribute name="linkend"> <xsl:copy-of select="@*"/> <xsl:value-of select="<extracted_text_string>"/>
</xsl:attribute> </xref> </xsl:if> </entry> </xsl:if> ... </row> </xsl:for-each> ...
Please, advise me how to extract the text string from within [ ] delimiters to pass it as a value for the <xref> expression.
Thanks a lot in advance!!!
Best wishes, Nancy
|
|
|
|

|
RE: RE: A tricky xref problem
That's why I called it "e1link". You could also have "e2"
and "e2link", etc. Just associate them by attribute name.
|
Hi Rob,
Thanks a lot for your suggestions! The second option you describe
could be ideal, if we could somehow associate between the 'e1' and
'e1link' attributes, so that the value of 'sectionID' could go to the
xref in the desired table entry (in this case, entry1). Is it possible?
Otherwise, how does the compiler know where to send sectionID - xref of
entry1 or entry 2?
Thank you a lot again!!!
My best wishes,
From:
Cavicchio_Rob@... <Cavicchio_Rob@...> Subject: RE:
[docbook-apps] RE: A tricky xref problem To: nancy_brndt@...,
docbook-apps@... Cc: bobs@... Date:
Tuesday, October 20, 2009, 9:38 AM
I think I understand now. You are
transforming *into* DocBook, and you want each entry's attribute value
to include not only the text for the entry, but the value of the
"linkend" attribute that will go into the DocBook
output.
You could certainly perform text string
manipulations so that if the "linkend" value were written in a
predictable way, you could extract its value. For example, if your
source document had this:
<row
e1="blue_sectionID">
then your transform could do
this:
<entry>
<xsl:value-of select="substring-before( @e1, '_' )"
/>
<xsl:if test="string-length( substring-after(@e1, '_')
)">
<xref>
<xsl:attribute name="linkend" />
<xsl:value-of select="substring-after( @e1, '_' )"
/>
</xsl:attribute>
</xref>
</xsl:if>
</entry>
which should produce
this:
<entry>
blue
<xref linkend="sectionID" />
</entry>
You could also use a separate
source attribute for the "linkend" attribute value; for
example:
<row e1="blue"
e1link="sectionID" />
That would achieve the same effect, but
avoids having to do all the string manipulations, and also avoids
having to designate a special character that you then can't easily use
in the actual content.
Hi Rob,
First of all, thanks a lot for
your quick response!
I think you misunderstood me, and
it's my fault. I'll try to provide more details about my
"design":
what i tried to do is to minimize the amount
of tags you need to type in, to create a table.
So, I
defined a kind of a macro, that builds the table's look and
feel, headings, etc.
<xsl:template
match="jstatuscodestable"> <xsl:variable
name="e1">
<xsl:apply-templates/> </xsl:variable> <xsl:variable
name="e2">
<xsl:apply-templates/> </xsl:variable>
<xsl:element
name="table"> <xsl:attribute
name="frame"> <xsl:value-of
select="'all'"/> </xsl:attribute> <xsl:attribute
name="id"> <xsl:value-of
select="@id"/> </xsl:attribute> <title><xsl:value-of
select="@t"/></title> <tgroup
cols="2"> <colspec colnum="1" colname="col1"
colwidth="*"/> <colspec colnum="2" colname="col2"
colwidth="1.5*"/> <thead>
<row> ...
</row> </thead> <tbody> <xsl:for-each
select="row">
<row>
<xsl:if
test="$e1">
<entry>
<xsl:value-of
select="@e1"/>
<xsl:if
test="contains('xref')">
<xref>
<xsl:copy-of select="@*"/>
<xsl:attribute name="linkend">
<xsl:copy-of
select="@*"/>
<xsl:value-of
select="<extracted_text>"/>
</xsl:attribute>
</xref>
</xsl:if>-->
</entry>
</xsl:if>
<xsl:if
test="$e2">
<entry>
<xsl:value-of
select="@e2"/>
</entry>
</xsl:if>
</row>
</xsl:otherwise> </xsl:choose>
</xsl:for-each> </tbody> </tgroup> </xsl:element> </xsl:template>
So,
to add such a table, I only need to
enter: <jstatuscodestable> <row
e1="blue" e2="red"> <row e1="black"
e2="yellow">
... </jstatuscodestable>
instead of entering
dozens of table elements each time.
But then, I
discovered that I can't add an <xref> within an entry.
I can't write: <row e1="blue (refer to <xref
linkend="sect_test"/>)" e2="red"/>
So I wonder,
if somehow a piece of text within e1's value (e.x. sect_test)
can be extracted and passed as a value for linkend I added (as
an example) in the first <entry> tag in the template
above. Of course, I would like to be able to add an xref in
any entry within the table.
I hope this time, my
explanation is clearer :-)
Thanks a lot in
advance!
Best wishes, Nancy
--- On Tue,
10/20/09, Cavicchio_Rob@...
<Cavicchio_Rob@...> wrote:
From:
Cavicchio_Rob@...
<Cavicchio_Rob@...> Subject: [docbook-apps] RE:
A tricky xref problem To: nancy_brndt@...,
docbook-apps@... Cc:
bobs@... Date: Tuesday, October 20, 2009, 8:20
AM
Your example is
confusing, because in standard DocBook, <row> does not
have "entry" attributes, only <entry> child
elements.
But assuming you know
that and this is really what you want, it sounds like you
are saying that you want to use the concatenated values of
the other attributes as the link ID. I think that you would
do that not by dynamically adding a "linkend" attribute, but
by modifying the "xref" template so that it retrieves the
values of those other attributes directly; something
like this:
<xsl:variable
name="linkID" select="@linkend" />
<xsl:choose>
<xsl:when test="id( $linkID )">
<xsl:call-template
name="createURI">
<xsl:with-param name="element" select="id( $linkID )"
/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template
name="createURI">
<xsl:with-param name="element" select="*[concat(@entry1,
@entry2, @entry3) = $linkID]" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
You would have to
make the entry text retrieval match the exact
pattern you want, but that's generally how I'd approach
it.
Hi all,
I wonder if there is a
way to extract a text string and pass it as a value
for the <xref linkend=""/> expression. For
example, when I write:
Some text
text text (see ref=[sect_test]),
I would like to take the text within the [ ]
delimiters and pass it as a value for the linkend
attribute of the xref element called in my
customized table template. The reason for this
special workaround is that I've created a custom
template that enables you to add a table row with
its entries using one command, like
so: <table> ...
<row
entry1="red" entry2="blue" entry3="black"/>
-which saves a lot of typing.
So, if I wish
to add a reference to some section from within
entry1, I can't write: <row entry1="red (refer
to <xref linkend="sect_test"/>)" entry2="blue"
entry3="black"/>
I need somehow to
customize my table template that says something
like: ... <xsl:for-each
select="row">
<row> <xsl:if
test="$entry1">
<entry>
<xsl:value-of
select="@entry1"/>
<xsl:if
test="contains('xref')">
<xref>
<xsl:copy-of
select="@*"/>
<xsl:attribute
name="linkend">
<xsl:copy-of
select="@*"/>
<xsl:value-of
select="<extracted_text_string>"/>
</xsl:attribute>
</xref>
</xsl:if>
</entry>
</xsl:if> ... </row> </xsl:for-each> ...
Please,
advise me how to extract the text string from within
[ ] delimiters to pass it as a value for the
<xref> expression.
Thanks a lot in
advance!!!
Best
wishes, Nancy
|
|
|
|