Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSLT

Reply
 
 
ak
Guest
Posts: n/a
 
      11-08-2005
Hi-

Is it possible to use XSLT (e.g. using xslLsort and xslutput), to
output/write a sorted XML file? Don't want an HTML browser rendering,
need a sorted XML file.

Thanks.

ak

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      11-09-2005

ak wrote:

> Is it possible to use XSLT (e.g. using xslLsort and xslutput), to
> output/write a sorted XML file? Don't want an HTML browser rendering,
> need a sorted XML file.


Yes, no problem, XSLT transforms in input tree into a result tree and
then optionally allows serializing that result tree as either html or
xml or text so of course you can use XSLT to transform XML to some
sorted XML, use
<xslutput method="xml" />
and then write your templates to sort the XML input the way you want.

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
ak
Guest
Posts: n/a
 
      11-09-2005
Thanks for your reply.

I've a doubt about getting the sorted XML. I'd still need a browser to
view sorted results. Instead I need to get a sorted XML file (i.e.
write to a new xml file). Is there a way to do that?

Alternatively, of all the ways I've seen to manipulate a DOM tree, I
couldn't figure out how I could dump a (sorted??) tree to XML file,
either after sorting it in memory, or applying some kind of
transformation while writing a file like that (using
javax.xml.Transform)!!

What I really need is to find the best way to take an XML file and
output another XML in which elements are sorted something like this-

(original fragment)
<action path="/StartLogin" forward="/Login.do"/>
<action path="/Login"
className="oracle.adf.controller.struts.actions.Da taActionMapping"
type="oracle.adf.controller.struts.actions.DataFor wardAction"
name="DataForm" parameter="/login.uix">
<set-property property="modelReference"
value="MemInfoUIModel"/>
<forward name="success" path="/Main.do?node_id=ED"/>
<forward name="failure" path="/Login.do?badlogin=1"/>
<forward name="disabled" path="/Login.do?badlogin=2"/>
</action>


Above is the original fragment.
If we say (in the configuration) order all 'action' tags by the 'path'
attribute and all 'forward' tags by 'name' I would expect the result
to look like this:

<action path="/Login"
className="oracle.adf.controller.struts.actions.Da taActionMapping"
type="oracle.adf.controller.struts.actions.DataFor wardAction"
name="DataForm" parameter="/login.uix">
<forward name="disabled" path="/Login.do?badlogin=2"/>
<forward name="failure" path="/Login.do?badlogin=1"/>
<forward name="success" path="/Main.do?node_id=ED"/>
<set-property property="modelReference"
value="MemInfoUIModel"/>
</action>
<action path="/StartLogin" forward="/Login.do"/>

(action tags are sorted by 'path' value and forward tags are sorted by
'name' values)

It's a big struts-config file which I'm trying to sort. Please don't
ask me why!! )

Thanks.

ak

 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      11-09-2005

ak wrote:

> I've a doubt about getting the sorted XML. I'd still need a browser to
> view sorted results. Instead I need to get a sorted XML file (i.e.
> write to a new xml file). Is there a way to do that?


Where does the XSLT or XPath specification say anything about browsers?
XSLT is not necessarily done in a browser, there are lots of XSLT
processors outside of browsers. Indeed, browser support for XSLT is
rather poor.


> What I really need is to find the best way to take an XML file and
> output another XML in which elements are sorted


Then write an XSLT stylesheet that does that (using <xslutput
method="xml" /> and <xsl:sort />) and use an XSLT processor that allows
you to serialize to a file.
In JAXP the transform method takes a javax.xml.transform.Result to
transform to and that can be a DOMResult or a SAXResult or a
StreamResult and a StreamResult can be constructed for a File or an
OutputStream.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
ak
Guest
Posts: n/a
 
      11-09-2005
Thanks Martin.

That's great help. I'll try that.

ak

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Including XSLT/XML document within a XSLT document dar_imiro@hotmail.com XML 4 12-13-2005 02:26 AM
Multiple XSLT Transforms using a Controller XSLT sneill@mxlogic.com XML 2 10-19-2005 11:00 AM
ANN: New low-cost XML Editor, XSLT Editor, XSLT Debugger, DTD/Schema Editor Stylus Studio Java 0 08-03-2004 03:53 PM
xslt alone or xslt/java for static site? ted XML 1 01-26-2004 10:41 AM
[XSLT]Passing values from Javascript to a XSLT variable Benjamin Hillsley XML 3 09-25-2003 04:50 AM



Advertisments