T
Tom Alsberg
Hi there...
I'm recently trying to get a bit acquainted with XML Schemas and XSL.
Now, I have a few questions about XSL stylesheets and templates:
* Is there a way to "enter" a child element of the currently matched
element in the template, so that XPath expressions inside would be
relative to that node? Specifically, I want to do this, in order to
be able to issue xsl:call-template to apply some templates to some
of the child nodes (of course redefining the template many times
with different relative paths is not an option)
* How can I logically AND two expressions in an XPath boolean
expression?
* Can I define more than one template for a match, with one being the
default, but being able to select different ones with
xsl:apply-templates? (I understand that modes are only to select
which elements to process, not which of a few templates to apply to
an element)
* Can you give some suggestions for the following scenario:
What I'm right now working on is defining an XSD type for human names:
<xs:complexType name="personname">
<xs:all minOccurs="1">
<xs:element name="title" type="xs:string" minOccurs="0" />
<xs:element name="given" type="xs:string" />
<xs:element name="middlename" type="xs:string" minOccurs="0" />
<xs:element name="surname" type="xs:string" />
<xs:element name="suffix" type="xs:string" minOccurs="0" />
</xs:all>
</xs:complexType>
What I want, is to have in an XSL stylesheet, a few different
templates for processing a personname, and be able to, in different
contexts (in the same stylesheet), call different templates for it.
E.g., a person:
<name>
<title>Mr.</title>
<given>Richard</given>
<middlename>Lee</middlename>
<surname>Tarpit</surname>
<suffix>the 17th</suffix>
</name>
could be processed as "Richard Tarpit", "Mr. Richard Lee Tarpit",
"Richard Tarpit the 17th", or "Mr. Richard Lee Tarpit the 17th". I
could then define templates for processing the name in those ways,
and in other places within the stylesheet, depending on the context,
call different templates on such a child element.
Thanks, any guidance appreciated,
-- Tom
I'm recently trying to get a bit acquainted with XML Schemas and XSL.
Now, I have a few questions about XSL stylesheets and templates:
* Is there a way to "enter" a child element of the currently matched
element in the template, so that XPath expressions inside would be
relative to that node? Specifically, I want to do this, in order to
be able to issue xsl:call-template to apply some templates to some
of the child nodes (of course redefining the template many times
with different relative paths is not an option)
* How can I logically AND two expressions in an XPath boolean
expression?
* Can I define more than one template for a match, with one being the
default, but being able to select different ones with
xsl:apply-templates? (I understand that modes are only to select
which elements to process, not which of a few templates to apply to
an element)
* Can you give some suggestions for the following scenario:
What I'm right now working on is defining an XSD type for human names:
<xs:complexType name="personname">
<xs:all minOccurs="1">
<xs:element name="title" type="xs:string" minOccurs="0" />
<xs:element name="given" type="xs:string" />
<xs:element name="middlename" type="xs:string" minOccurs="0" />
<xs:element name="surname" type="xs:string" />
<xs:element name="suffix" type="xs:string" minOccurs="0" />
</xs:all>
</xs:complexType>
What I want, is to have in an XSL stylesheet, a few different
templates for processing a personname, and be able to, in different
contexts (in the same stylesheet), call different templates for it.
E.g., a person:
<name>
<title>Mr.</title>
<given>Richard</given>
<middlename>Lee</middlename>
<surname>Tarpit</surname>
<suffix>the 17th</suffix>
</name>
could be processed as "Richard Tarpit", "Mr. Richard Lee Tarpit",
"Richard Tarpit the 17th", or "Mr. Richard Lee Tarpit the 17th". I
could then define templates for processing the name in those ways,
and in other places within the stylesheet, depending on the context,
call different templates on such a child element.
Thanks, any guidance appreciated,
-- Tom