Subject: Re: [xsl] Splitting an element into two different places while merging in another From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Tue, 15 Oct 2002 15:47:46 +0100 |
Hi Richard, > I am stuck on how to correctly handle the arrest records. Everything > seems to process OK but I get two legal_assessments elements where I > need/want/can only have one. Usually when that kind of thing occurs it's because you're generating the elements that you're getting too many of at the wrong 'level' in the stylesheet. In this case, you're generating them within a template that matches each military_legal_assessments and each arrest_records element in your document, so you get one legal_assessments element for each -- 2 in total. Instead, you should generate the legal_assessments element in a template that matches on an element that only occurs once in the stylesheet, such as the client element. Personally, I'd use a couple of modes so that you can process the same military_legal_assessment in two different ways -- once to produce a legal_assessment, and once to produce a military_assessment: <xsl:template match="client"> <client> <legal_assessments> <xsl:apply-templates select="military_legal_assessments | arrest_records" mode="legal_assessment" /> </legal_assessments> <military_assessments> <xsl:apply-templates select="military_legal_assessments" mode="military_assessment" /> </military_assessments> </client> </xsl:template> <xsl:template match="military_legal_assessment | arrest_record" mode="legal_assessment"> <legal_assessment> <xsl:copy-of select="@*" /> <xsl:copy-of select="node()[name() = $legal_assessment_fields]" /> </legal_assessment> </xsl:template> <xsl:template match="military_legal_assessment" mode="military_assessment"> <military_assessment> <xsl:copy-of select="@*" /> <xsl:copy-of select="node()[not(name() = $legal_assessment_fields)] </military_assessment> </xsl:template> (Note that this stylesheet relies on the built-in templates to process each military_legal_assessments element by processing its contents, and similarly for the arrest_records element.) Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Splitting an element into two, Richard Rowell | Thread | [xsl] XSLT template library creatio, sguazt |
[xsl] XSLT template library creatio, sguazt | Date | Re: [xsl] Pagination in xsl-fo, David Tolpin |
Month |