Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Content Management (Extended ECM)
API, SDK, REST and Web Services
How to transform a xml-string in memory ?
Kai-Uwe_Schmidt_(kus_-_(deleted))
Hi folks,i get a XML-String via a socket like :sData = now i want to transform the value of sData to HTML.i got a xsl working for my nodes, but how can i do the transformation w/o creating a temp-file and passing the file-name ?xsl.SetInput() just accepts a DomNode or a Filename (String)Any hints ?regardsKai-Uwe
Find more posts tagged with
Comments
Francisco_Alcala-Soler_(iaea_001user3_-_(deleted))
Message from via eLinkHi Kai-Uwe,> Any hints ?Here are two ideas, whereby I have implemented and seen work before only thefirst one:a) Generating the DOMNode on the fly, like I do with the following XSL stylesheet: DOMNode xmlNode, cloneNode DOMElement xmlElement DOMDocument xmlDocument = DOMDocument.New() xmlElement = xslDocument.CreateElement( "xsl:stylesheet" ) xmlElement.SetAttribute( "version", "1.0" ) xmlElement.SetAttribute( "xmlns:xsl","
http://www.w3.org/1999/XSL/Transform
" ) cloneNode = xmlElement.CloneNode( TRUE ) xmlNode = xslDocument.AppendChild( cloneNode ) xmlElement = xslDocument.CreateElement( "xsl:template" ) xmlElement.SetAttribute( "match", "/" ) cloneNode = xmlElement.CloneNode( TRUE ) xmlNode = xmlNode.AppendChild( cloneNode ) xmlElement = xslDocument.CreateElement( "results" ) cloneNode = xmlElement.CloneNode( TRUE ) xmlNode = xmlNode.AppendChild( cloneNode ) etc.b) Investigate whether a DOMParser object has a ParseString() instancemethod that would allow you to convert your sData string into a DOMNode.It's not documented and I am only guessing, but if you take a look at thescript LLIAPI:LLIApi Root:XML:ImportCommon:SaxParserObject:Parse, it seemsthat the SAXParser has it, so you might be lucky and find it on theDOMParser as well, which you then could use like this (untested): String sData = DOMParser xmlParser = DOMParser.New() xmlParser.SetDoValidation( FALSE ) xmlParser.SetDoNamespaces( FALSE ) Assoc retVal = xmlParser.ParseString( sData ) if( retVal.ok ) DOMDocument doc = xmlParser.GetDocument() [...] endI am not sure if the DOMDocument doc is already something that you can passto xsl.SetInput() or whether you have to do further work to retrieve aDOMNode. The documentation says DOMNode is an interface class implemented byall DOM objects, but I am not sure if this applies to the DOMDocument, soyou'll have to test it.Regards, CurroThis email message is intended only for the use of the named recipient.Information contained in this email message and its attachments may beprivileged, confidential and protected from disclosure. If you are not theintended recipient, please do not read, copy, use or disclose thiscommunication to others. Also please notify the sender by replying to thismessage and then delete it from your system.
eLink User
Message from Kai-Uwe Schmidt via eLinkHi,...> RE How to transform a xml-string in memory ?> Posted by Alcala-Soler, Francisco J on 04/16/2004 03:23 AM...> > a) Generating the DOMNode on the fly, like I do with the following XSL style> sheet:> > DOMNode xmlNode, cloneNode> DOMElement xmlElement> > DOMDocument xmlDocument = DOMDocument.New()> > xmlElement = xslDocument.CreateElement( "xsl:stylesheet" )> xmlElement.SetAttribute( "version", "1.0" )> xmlElement.SetAttribute( "xmlns:xsl",> "
http://www.w3.org/1999/XSL/Transform
" )> cloneNode = xmlElement.CloneNode( TRUE )> xmlNode = xslDocument.AppendChild( cloneNode )> xmlElement = xslDocument.CreateElement( "xsl:template" )> xmlElement.SetAttribute( "match", "/" )...if i understand you, the right way here is to manually parse my XML-String and append the parsed nodes one by one. Thats of course not the way i want to go
> b) Investigate whether a DOMParser object has a ParseString() instance...That function isn't exported by the XML-drop in
If i compare the c++ api of Xerces/Xalan with the drop in i have to guess, that the developer havent got the buget to implement the complete posibile functions :/The Xalan API looks like it could serve mv deserves but the dropin can't :/This should be a feature-request for Opentext. I will go now and write my own Xalan dropin. Please stop me by telling me the supported way to fullfill my request :)regards Kai-Uwe
Francisco_Alcala-Soler_(iaea_001user3_-_(deleted))
Message from via eLink> if i understand you, the right way here is to manually parse > my XML-String and append the parsed nodes one by one. Thats > of course not the way i want to go :/I suspected it ;-), but thought I'd propose it anyway.> This should be a feature-request for Opentext. Yes, please. I second your initiative.> I will go now and write my own Xalan dropin. Please stop me > by telling me the supported way to fullfill my request :)I can't think of any other ways; sorry. Let us know what you go for, ifsomeone else is able to assist you.Regards, CurroThis email message is intended only for the use of the named recipient.Information contained in this email message and its attachments may beprivileged, confidential and protected from disclosure. If you are not theintended recipient, please do not read, copy, use or disclose thiscommunication to others. Also please notify the sender by replying to thismessage and then delete it from your system.