Hwo to rewrite attribute to tags generically

moroder

Usenet Archive
Joined
Oct 15, 2004
Messages
1
Reaction score
0
Hi,

I'd like to rewrite this (some might recognize it as MarcXML)

....
<datafield tag="245" ind1="0" ind2="0">
<subfield code="a">Corpus Rubenianum Ludwig Burchard :</subfield> <subfield code="b">an illustrated catalogue raisonné of the work of Peter Paul Rubens.</subfield> <subfield code="n">P.2,</subfield> .... </datafield> ...

to this
....
<data245 ind1="0" ind2="0">
<suba>Corpus Rubenianum Ludwig Burchard :</suba>
<subb>an illustrated catalogue raisonné of the work of Peter Paul Rubens.</subb> ...

Any tips? I've done things like this

<xsl:template match="@code"><xsl:element name="c{.}"><xsl:value-of select="parent::node"/></xsl:element></xsl:template>

but I get only halfway, and get duplicate values allover the place, and...
etc :-(

Thanks!

moro
 

David Carlisle

Usenet Archive
Joined
Jan 5, 2000
Messages
609
Reaction score
0
(don't use "tag" when you mean "element", XSLT can't process tags)

Something like

<xsl:template match="datafield">
<xsl:element name="data{@tag}">
<xsl:copy-of select="@*[not(name='tag')]"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>

<xsl:template match="subfield">
<xsl:element name="sub{@code}">
<xsl:copy-of select="@*[not(name='code')]"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
548,208
Messages
3,104,799
Members
249,594
Latest member
henrywalsh

Latest Threads

Top