473,734 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

for-each IDREF

Dormilich
8,658 Recognized Expert Moderator Expert
Hello,

I'm back with a problem, where I need help with starting.
I got an XML file that contains a number of elements with IDREF type attributes:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" ?>
  2. <root>
  3. // these elements contain all the info for the groups
  4. // name is of type ID
  5.   <group name="group1" … />
  6.   <group name="group2" … />
  7.   <group name="group3" … />
  8.   <collection>
  9. // group is of type IDREF
  10. // there can be any number of elements
  11.     <item group="group1">…</item>
  12.     <item group="group1">…</item>
  13.     <item group="group2">…</item>
  14.   <collection>
  15. <root>
in XSL I want to loop over each group of <item> inside the <collection> (ideally using the idref() function) but I do not know all the values of the IDREF attribute (this number may change over time/file/element). Is there any way to get these values?
Expand|Select|Wrap|Line Numbers
  1. // desired result
  2. <div id="group1">
  3.   <a … >
  4.   <a … >
  5. </div>
  6. <div id="group2">
  7.   <a … >
  8. </div>
I know that I could loop over all elements (using <xsl:sort>) and check if the attribute value is still the same. Is there a more elegant way? (something like getting the IDREF attribute values first and then call it by idref() (or @group))

Is it possible to somehow get all the ID values of <group> and iterate over each of them?

thanks

PS: once I know all the IDREFS inside <collection> there are no problems I can foresee
Dec 8 '08 #1
4 2491
jkmyoung
2,057 Recognized Expert Top Contributor
Do you mean this? If not, what more are you looking for; what do you mean by idref? Is this a processor specific function, eg Xalan?

Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="group">
  2.   <div id="{@name}">
  3.     <xsl:apply-templates select="//collection/item[@group = current()/@name]"/>
  4.   </div>
  5. </xsl:template>
  6.  
Dec 8 '08 #2
Dormilich
8,658 Recognized Expert Moderator Expert
@jkmyoung
I mean this:
Expand|Select|Wrap|Line Numbers
  1. <!ELEMENT item ...>
  2. <!ATTLIST item 
  3.     group    IDREF    #IMPLIED
  4.     ... >
I'll dive into the code tomorrow...

regards

PS: XML Schema also know ID/IDREF type attribute definitions
Dec 8 '08 #3
Dormilich
8,658 Recognized Expert Moderator Expert
currently I'm looking into muenchian grouping. will post back if I can see some light....
Dec 9 '08 #4
Dormilich
8,658 Recognized Expert Moderator Expert
solved it using Muenchian Grouping (pretty much the thing I needed).
files (too long to post):
XML (gives YSOD in FF)
XSL
DTD
Dec 9 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
9420
by: Xerxes | last post by:
Hi, is there any script to authenticate an email address entered in a form field? I used the php mail() function, using the following (where my email field on the form is called "email"): $email = explode('@',$email); $mailhost = $email; $mailhost=$mailhost.".";
4
6429
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as well as some color coding, etc. Having trouble finding the same in an editor that'll run on OS X. -- Floydian Slip(tm) - "Broadcasting from the dark side of the moon"
0
2891
by: Verizon | last post by:
Has anybody ever heard of support for the book: "Secure PHP Development" by: Mohammed J. Kabir I'm trying to run one of his PHP solutions called "Web Forms Manager" I haven't been able to get it up and running. Thanks in advance!
0
2012
by: panic | last post by:
If you are not familiar with the palm DB apps I am refering to, they are applications that allow you to graphically create a db by adding fields(columns) and then creats a form so you can enter the info, and also you can display it in row form. So I am looking for a program that would be a type of online record keeper, where you can via the web, create a database, or table, add fields, and be able to add records, and view them in a a...
0
3568
by: Robert Freund | last post by:
I've been looking for a good and free code beautifier that runs on linux. About the only ones I found where Trita (www.trita.com), which costs money and only runs on windows. The other one was Beautify PHP (www.bierkandt.org/beautify) which does not offer all the features I'd like to have. I'm also more interested in something that is not written in php itself because I want to reformat large amounts of code quite often, and I guess...
33
9864
by: Frank | last post by:
What is the best IDE for developing PHP applications? What do you use and why? Thanks.
4
5958
by: john Q | last post by:
I found a PHP based email obfuscator for use in websites, where the source HTML (PHP, actually) file doesn't contain the actual email address in the Mailto tag, but generates it and that generated page (containing a full and conventional Mailto: tag) is what is ultimately presented to the user. The intent is to thwart Spam bots and spiders, by NOT having the email address in the original HTML Source, but ultimately presenting it to...
0
2023
by: Mr.Bogi | last post by:
Is anyone aware of an open source report generation library for php/mysql? Basically a freeware/opensource alternative to Crystal Reports. thanks
0
2199
by: Alex | last post by:
Bottom line: would like to get a weblog and bulletin board going. Would like to use phpBB2 and movabletype. I have movabletype working using mysql. Apache and php were on my linux red hat 7.2 out of the box it seems. hello.php worked with the original setup. Somewhere along the time of installing MySQL database & DBD::mysql and a php-mysql rpm my hello.php stopped working and is now just showing text-source in the web browser.
5
2228
by: ChronicFatigue | last post by:
Hello My current host has register_globals switched on in their php.ini file. Would it be prudent for me to design code which works when register_globals is switched off in case I switch hosts in the future? If I dont is it normally straightforward to edit the code so that a script can be run with register_globals off in the future? Just trying to future proof my work abit.
0
8946
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8776
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.