473,804 Members | 2,184 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting escaped markup to nodeset

2 New Member
Hi,
I am new to coding in Xslt and am stuck up on a problem for a very long time.
I have to convert an xml file to html using xslt.
I am using javax.xml.trans form API for this.
The xml file i have contains data in the following format

<person>
<name>PERSON_NA ME</name>
<addressXML>
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&ltstreet&gtSTR EETNAME&lt/street&gt &ltcity&gtCITYN AME&lt/city&gt
</addressXML>
</person>

ie.the xml contains another xml file as value in escaped markup format.
Now since the value of addressXML is a text i cannot xpath.

Is there any way i can convert this text to a nodeset so i can access the values inside it by using xpath.
Currently I am using sub-string after and sub-string before to extract data but this process is giving out of memory errors for large xml files.
I have tried extension functions but could not succeed.(May be i dont know the right way)
Please help, I have been stuck up with this for a long time.
Thank you.
Nov 6 '08 #1
4 3331
Dormilich
8,658 Recognized Expert Moderator Expert
you could store the output (which should be xml) in a variable and use that again. like
Expand|Select|Wrap|Line Numbers
  1. // I have no clue of java... so these are symbolic commands
  2. inputXML = "original_xml_file.xml"
  3. inputXSL = "first_transformation.xsl" // print out the escaped text as xml
  4. outputXML = transform(inputXML, inputXSL)
  5. writeToFile(outputXML, file_name)
  6. input2XSL = "second_transformation.xsl" // does what you intended in the first place
  7. output2 = transform(inputXML, input2XSL)
the first transformation is used to convert the escaped xml text into real xml.
the second transformation can now access parts of the result xml via the document() function while working on the original xml file.

(I hope that's not too complicated written)

of cause the easiest way would be to use unescaped xml, but I don't know where the escaped xml originates...

regards
Nov 6 '08 #2
otis
6 New Member
I was going to suggest something similar.

Parse the file as a string before loading it as XML and replace &gt; with > and &lt; with < and <?xml version="1.0" encoding="UTF-8"?> with nothing and you will have

<addressXML>
<street>STREETN AME</street>
<city>CITYNAM E</city>
</addressXML>

Is this how you were doing it before where you were having problems with it slowing down?
Nov 6 '08 #3
vaibhavp
2 New Member
Thanks a lot for replying.
I have a doubt If i parse the file as a string, how do i do it.
I am not aware if to parse it through Java. or xslt.
I thought about the first post and got an idea from that.
Instead of creating a new xml file for that section and using document() function
How about using a similar two step transformation to convert the first xml to a clean new xml file. and use it to transform to html?
Will this be a good opion?.. Because i will avoid Java Overhead of creating a new file for each such tag i encounter
Thanks to both of you..
Nov 7 '08 #4
Dormilich
8,658 Recognized Expert Moderator Expert
you can do that as well.

how does it come that you get the escaped xml? if it is possible to fix that, it'd be the best solution I can think of.

jkmyoung is imho the master/xml god of xsl:copy procedures. there are some recent threads which can help you with copy issues.

regards
Nov 7 '08 #5

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

Similar topics

4
3525
by: Brad | last post by:
Help, I have a really complicated XPATH request I can't wrap my head around I have an XML nodeset like this: <a> <a1 attr="key">Use</a1> <a1 attr="val">Value1</a2> </a> <a> <a1 attr="key">DontUse</a1>
8
5746
by: prabha | last post by:
Hello Everybody, I have to conert the word doc to multiple html files,according to the templates in the word doc. I had converted the word to xml.Also through Exsl ,had finished the multiple output html files. The problem is while reading through the worddoc paragraph,the special characters are not identified. So in the xml file,it's just storing that as "?".So I couldn't able to retrive the characters in my ouput html files.
1
2465
by: Damien Goutte-Gattat | last post by:
I am using the .NET framework v2.0.40607 with Visual C# Express and I would like to create some custom XPath functions to use directly in a XSLT stylesheet. I called System.Xml.Query.XmlArgumentList.AddExtensionObject(string, object) to register the functions I've written. The functions that take a String, Boolean or Number parameter work perfectly. However, I do not know how to create a function that will accept a Nodeset as a...
0
1746
by: KathyB | last post by:
Hi, Using the following in an asp.net procedure. I get the error "The expression passed to this method should result in a NodeSet". Dim xDoc As New Document() The line causing the error is: Dim n as XmlNode = xDoc.SelectSingleNode("//Station="Station1"]/WI/]/@order")
0
1251
by: Hoi-Polloi | last post by:
Hi all I want to use an xpath query to get a set of xmlNodePtr , but I don't want to keep the xmlXPathObject around. See the function below. I want to: * make xpath query and get an xmlXPathObjectPtr back * get a pointer (np) to the XPathObjectPtr->nodesetval->nodeTab * free XPathObjectPtr * return the pointer np ... but I'm not sure if np is still valid
2
1685
by: Yarik | last post by:
Hello, I am not sure the subject of my post adequately describes the problem I am trying to solve, so I think a specific example would be helpful. Let's say there are XML descriptions of products like this one: <!-- File: Products.xml --> ... <Product id="p1">
11
2015
by: Jean-François Michaud | last post by:
Hello all, I'm having a little problem, The UTF-8 parser we are using converts the newline entity ( ) within an attribute that we are using to paliate CSS limitations. After the parser has gone through the document, the entity is converted to \n, which then effectively tosses out the window the behavior we are getting by keepinig the entity AS IS within the document.
14
1566
by: eric.goforth | last post by:
Hello, Is there any way to directly access an element in a nodeset? For example, if working with: <blahs rec_count="16"> <blah> <yada>abc</yada> </blah>
9
11574
by: Michael Goerz | last post by:
Hi, I am writing unicode stings into a special text file that requires to have non-ascii characters as as octal-escaped UTF-8 codes. For example, the letter "Ã" (latin capital I with acute, code point 205) would come out as "\303\215". I will also have to read back from the file later on and convert the escaped characters back into a unicode string.
0
9712
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
10595
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
10343
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...
1
10341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10089
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...
0
9171
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
7634
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
5530
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
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.