I'll check these out Monday when I get back to work. I read the first
nudge from Robert and now just saw Ken's code an yours.
Not sure what more your looking for on <person>. I need to keep them
but now wrap what are associated elements. I think my desired output
shows everything unless I'm missing something.
..dan
At 01:53 PM 9/23/2011, you wrote:
On Fri, 2011-09-23 at 12:25 -0700, dvint(_at_)dvint(_dot_)com wrote:
> I'm trying to use XSLT to do a conversion from one version of the S1000D
> spec to another. So in the older version you can have this:
>
> <reqpers>
> <person man="1"/>
> <perscat category="tech"/>
> <trade>foo</trade>
> <person man="2"/>
> <perscat category="techa"/>
> <perskill skill="sk05"/>
> <trade>bar</trade>
> <esttime>23</esttime>
> </reqpers>
>
> In the newer version you have a nested structure:
>
> <reqPersons>
> <person man="1">
> <personCategory personCategoryCode="tech"/>
> <trade>foo</trade>
> </person>
> <person man="2">
> <personCategory personCategoryCode="techa"/>
> <personSkill skillLevelCode="sk05"/>
> <trade>bar</trade>
> <esttime>23</esttime>
> </person>
> <reqPersons>
Although it's a grouping problem I'd quite likely (depending on the
actual schemas) have a template to match person that looked ahead and
called apply-templates on the following elements in a mode, and have
templates e.g. for trade, that were empty --
<xsl:template match="trade|perskill|esttime" />
<xsl:template match="trade" mode="nested">
<xsl:copy-of select="."/> <!--* or whatever *-->
</xsl:template>
I see this is similar to your approach, so...
>
> I can use the following sibling to pull the elements under a new <person>
> tag, but the problem is that none of the following elements are requried.
> So this will work if I have a consistent combination of elements.
>
> <xsl:template match="person">
> <person>
> <xsl:call-template name="processSecurityAttributes"/>
> <xsl:call-template name="processsChangeAttributes"/>
> <xsl:call-template name="processsIDAttributes"/>
> <xsl:call-template name="processsApplicabilityAttributes"/>
> <xsl:if test="@man">
> <xsl:attribute name="man" select="@man"/>
> </xsl:if>
You can do all those at once with a mode:
<xsl:apply-templates
select="processSecurityAttribuets|removeSocks"
mode="my-happy-person-mode" />
Then you don't need the for-eaches you're using.
For the two-person-elements question you need to say what you want to
happen in that case bfore anyone can help you with it :-)
Liam
--
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
---------------------------------------------------------------------------
Danny Vint
Panoramic Photography
http://www.dvint.com
voice: 619-938-3610
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--