473,387 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Hwo to rewrite attribute to tags generically

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
Jul 20 '05 #1
1 1147

(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
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: yamini | last post by:
Here I am trying to use tag files in JSP2.0 with tomcat 5. test.jsp ------- %@ taglib prefix="test" tagdir="/WEB-INF/tags" %> <html> <head> <title>Untitled Document</title> </head> <body>
0
by: Ingrid | last post by:
Am I right in thinking that datatyping at element level ie <xs:element name="num" type="xs:integer"> and specifying a choice of attribute values ie <xs:attribute name="kind"> <xs:simpleType>...
4
by: Stan Brown | last post by:
In converting my pages to 4.01 Strict, I've been removing ALIGN attributes everywhere. I was surprised to notice that a page that validated contained a <td align=left>. Sure enough, when I...
6
by: Richard | last post by:
<a href="#" name="sample">link 1</a> <a href="#" name="sample">link 2</a> Would this be invalid use of the name? If I wanted to have a function that would be acted upon by detection of the...
188
by: christopher diggins | last post by:
I have posted a C# critique at http://www.heron-language.com/c-sharp-critique.html. To summarize I bring up the following issues : - unsafe code - attributes - garbage collection -...
1
by: Heron | last post by:
Hi, I'm new to regular expressions and having troubles recreating one that would match tags with there attribute and content. Example on which i'm doing the match: protected void...
0
by: awburns | last post by:
I have a custom server control I've written, which I've subclassed from the System.Web.UI.Control class. When I drag it from the toolbar to the page, the following text is put into the aspx...
2
by: Icarus - iD_Ten_T helper | last post by:
I am currently teaching myself PHP, JS, HTML and CSS. I would say I am a beginner to interemediate at varying levels within all 4, however I have some queries and I wonder if any of you can...
5
by: John Gordon | last post by:
My XSLT files have many occurrences of this general pattern: <a> <xsl:attribute name="href"> <xsl:value-of select="xyz" /> </xsl:attribute> </a> When I execute an XSL transform, the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.