473,608 Members | 2,689 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing the order of the XML

samueln12
28 New Member
I want to change the order the caption according to their citation present in the text.

For example:

Expand|Select|Wrap|Line Numbers
  1. <book>
  2. <chapter>
  3. <title/>
  4. <p>1 Some text goes here <xref rid="F1">Figure 1</xref></p>
  5. <p>2 Some text goes here <xref rid="F2">Figure 2</xref></p>
  6. <p>3 Some text goes here <xref rid="F4">Figure 4</xref></p>
  7. <p>3 Some text goes here <xref rid="F3">Figure 3</xref></p>
  8. <p>4 Some text goes here</p>
  9. <p>5 Some text goes here <xref rid="F5">Figure 5</xref></p>
  10. <p>6 Some text goes here <xref rid="F7">Figure 7</xref></p>
  11. <p>7 Some text goes here</p>
  12. <p></p>
  13. <floats>
  14. <figure id="F1">Figure 1. Figure one text goes here</figure>
  15. <figure id="F2">Figure 2. Figure one text goes here</figure>
  16. <figure id="F3">Figure 3. Figure one text goes here</figure>
  17. <figure id="F4">Figure 4. Figure one text goes here</figure>
  18. <figure id="F5">Figure 5. Figure one text goes here</figure>
  19. <figure id="F6">Figure 6. Figure one text goes here</figure>
  20. <figure id="F7">Figure 7. Figure one text goes here</figure>
  21. </floats>
  22. </chapter>
  23. </book>
After changing the XML should look like this:
Expand|Select|Wrap|Line Numbers
  1. <book>
  2. <chapter>
  3. <title/>
  4. <p>1 Some text goes here <xref rid="F1">Figure 1</xref>
  5. <figure id="F1">Figure 1. Figure one text goes here</figure>
  6. </p>
  7. <p>2 Some text goes here <xref rid="F2">Figure 2</xref>
  8. <figure id="F2">Figure 2. Figure one text goes here</figure>
  9. </p>
  10. <p>3 Some text goes here <xref rid="F4">Figure 4</xref></p>
  11. <p>3 Some text goes here <xref rid="F3">Figure 3</xref>
  12. <figure id="F3">Figure 3. Figure one text goes here</figure>
  13. <figure id="F4">Figure 4. Figure one text goes here</figure>
  14. </p>
  15. <p>4 Some text goes here</p>
  16. <p>5 Some text goes here <xref rid="F5">Figure 5</xref>
  17. <figure id="F5">Figure 5. Figure one text goes here</figure>
  18. </p>
  19. <p>6 Some text goes here <xref rid="F7">Figure 7</xref>
  20. <figure id="F6">Figure 6. Figure one text goes here</figure>
  21. <figure id="F7">Figure 7. Figure one text goes here</figure>
  22. </p>
  23. <p>7 Some text goes here</p>
  24. <p></p>
  25. <floats>
  26. </floats>
  27. </chapter>
  28. </book>
Please guide me how to do this

Thanks
Sam
Apr 12 '10 #1
8 1700
Dormilich
8,658 Recognized Expert Moderator Expert
which language do you want to use for that?
Apr 12 '10 #2
samueln12
28 New Member
XSLT version=2.0
Apr 12 '10 #3
jkmyoung
2,057 Recognized Expert Top Contributor
?
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="xref">
  2.   <xsl:copy-of select="."/>
  3.   <xsl:copy-of select="descendant::chapter/floats/figure[@id = current/@rid]"/>
  4. </xsl:template>
  5.  
I don't understand how you know where to put
<figure id="F6">Figure 6. Figure one text goes here</figure>
Apr 12 '10 #4
samueln12
28 New Member
@jkmyoung
That is the client requirement. If any citation missing we have to place after the preceding citation.
Apr 12 '10 #5
jkmyoung
2,057 Recognized Expert Top Contributor
Could you explain the figure3 and figure4 relation?

Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="xref"> 
  2.   <xsl:copy-of select="."/> 
  3.   <xsl:apply-templates select="descendant::chapter/floats/figure[@id = current/@rid]"/> 
  4. </xsl:template> 
  5. <xsl:template match="floats"/> <!-- may or may not be necessary depending on your layout-->
  6. <xsl:template match="figure">
  7.     <xsl:for-each select="preceding-sibling::figure[1]">
  8.       <xsl:if test="not(//xref[@rid = current()/@id])"><!-- orphan? -->
  9.          <xsl:apply-templates select="."/>
  10.       </xsl:if>
  11.     </xsl:for-each>
  12.     <xsl:copy-of select="."/>
  13. </xsl:template>
  14.  
Apr 12 '10 #6
samueln12
28 New Member
@jkmyoung
If citation are not in order e.g. Figure 4 first and Figure 3 next, Figure 4 should placed after figure 3, even though figure 4 citation in first.

For example, if figure 3 not cited in the text then figure 3 go under figure 2. and Figure 4 place under the Figure 4 paragraph

I hope this will help u
Apr 12 '10 #7
jkmyoung
2,057 Recognized Expert Top Contributor
Actually that pretty much completely screws it up.

In order to get correct order processing, you will have to process using the figures. Processing will have to be done linearly with much checking back, and with state variables, not parallel.

At this point I would recommend not using XSLT.
Apr 12 '10 #8
samueln12
28 New Member
@jkmyoung
ok thanks i done this using perl. but i know that using XSLT its very easy.
Apr 12 '10 #9

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

Similar topics

15
2379
by: oom | last post by:
I am a bit of a newbie when it comes to python, when working with lists today I noticed some very odd behaviour, any suggestions welcome: Python 2.2.3 (#1, Nov 6 2003, 14:12:38) on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> firstlist= >>> secondlist=firstlist >>> print (firstlist,secondlist)
2
2500
by: Paolo Pignatelli | last post by:
I am trying to get an output/file like this (below) in an XML file (MyXmlFile.xml) (which I will use for a slide show) -- <gallery timer="3" order="sequential" fadetime="2" looping="yes" xpos="0" ypos="0"> <image path="images2/Test1.jpg" />
0
2190
by: Tom | last post by:
Using AccessXP - Access2000 In my application, when an order is entered, inventory is automatically adjusted, a pull list is created, items are pulled to fill the order, and the order is packaged for shippment. The order is then held pending payment and finally shipped when payment is received. Sometimes prior to shipment the customer calls and wants to change one or more items, wants to change the quantity of one or more items or wants...
16
2436
by: StenKoll | last post by:
Help needed in order to create a register of stocks in a company. In accordance with local laws I need to give each individual share a number. I have accomplished this by establishing three tables (se below) then I run a query giving me a running total, which give me the first stock in the batch purchased by an individual, then I use this number and add the number of shares in order to find the number of the individuals' last share. So...
1
1972
by: Shawn Benson | last post by:
I have a Windows form where a user enters an order number which returns a dataset that is bound to a datagrid. The problem is when a user clicks on a cell in the datagrid, then enters another order to get information for, everything is updated with the new data except the cell in the grid that was selected. This behavior does not occur when a table style is not applied to the datagrid. How do I refresh the datagrid so that the cell in...
7
5257
by: Dan Sikorsky | last post by:
How do you iterate thru a dataset to change money fields to a different value? Here's what I have. My dataset is filled directly from a stored procedure. ' Create Instance of Connection and Command Object Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")) Dim myCommand As New SqlDataAdapter("OrdersList", myConnection)
32
3660
by: deko | last post by:
I have a popup form with a textbox that is bound to a memo field. I've been warned about memo fields so I'm wondering if I should use this code. Is there any risk with changing the form's RecordSource like this? Am I asking for trouble doing this with a memo field? Thanks in advance. Private Sub cmdNextNote_Click() Dim lngNid As Long If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord
6
1689
by: Jim Devenish | last post by:
I have 3 views, two of which depend on the other: CREATE VIEW dbo.CustomerListQueryAccounts AS SELECT dbo.CustomerListQuery.* FROM dbo.CustomerListQuery WHERE (isProspect = 0) CREATE VIEW dbo.CustomerListQueryProspects AS
4
6627
by: Jon Slaughter | last post by:
Is there any method to temporarily disable focus changing?(I assume only method is tab or mouse?) This problem has been tieing me up for a while and nothing seems to work. The only thing that I *know* will work is to disable all tab stops on all controls. This brute force method doesn't seem like a good idea though. What I wanted to do was take control the control enter/leave and mouse enter/leave and "switch back" the focus when it is...
5
2583
by: marton | last post by:
Hi there, I'm new to posting on the forum, and I've been working with MS Access for a couple of years, but and other than that know nothing about programming. I have a fairly simple, networked, Access database created with Access 2003. It is accessed from several different computers in my department (I don't know which computers or how often). About 8 people are entering data with an unbound form (which also records computer ID, date and...
0
8050
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
7987
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
8472
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8464
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8324
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6000
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
5471
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4015
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1318
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.