File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes How to save all nodes in a variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to save all nodes in a variable" Watch "How to save all nodes in a variable" New topic
Author

How to save all nodes in a variable

Brian Grey
Ranch Hand

Joined: Nov 15, 2002
Posts: 43
I'd like to save the all structure in a xsl:variable, but this code doesn't work. Can someone help me?

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ms="urn:schemas-microsoft-com:xslt"
xmlns:user="userhtml">
<xsl utput method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:variable name="xmlInput">
<xsl:copy-of select="."/>
</xsl:variable>

<XSLTValidationResults>
<!-- test -->
<xsl:value-of select="$xmlInput"/>
</XSLTValidationResults>
</xsl:template>
</xsl:stylesheet>
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
Brian, it looks that you need to use xsl:copy-of in the second case also:
...
<XSLTValidationResults>
<!-- test -->
<xsl:copy-of select="$xmlInput"/>
</XSLTValidationResults>


Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
Brian Grey
Ranch Hand

Joined: Nov 15, 2002
Posts: 43
You're right, I found it after I posted.
I wanted to keep the xml in xsl:variable because it would be used in VBScript function like this:
<xsl:copy-of select="user:AdditionalBusinessRules($xmlInput)"/>
But I got this error :
Microsoft VBScript runtime error
Type mismatch: 'objXML.LoadXML'
I need your help again
<ms:script language="VBScript" implements-prefix="user">
function AdditionalBusinessRules(strXML)
Set objXML = CreateObject("MSXML2.DOMDocument.3.0")
Set objXSL = CreateObject("MSXML2.DOMDocument.3.0")

objXML.async = False
objXML.LoadXML strXML

objXML.save ("D:\CAS\DEV\Data\CAS_Result_AdditionalBusinessRules_Input.xml")
objXSL.async = False
objXSL.Load ("D:\CAS\DEV\Data\BCEECreditApp_AdditionalBusinessRules_2.1.5.xsl")

strXMLResult = objXML.transformNode(objXSL)

objXML.LoadXML strXMLResult
objXML.save ("D:\CAS\DEV\Data\CAS_Result_AdditionalBusinessRules_Output.xml")

AdditionalBusinessRules = objXML.xml
End function
</ms:script>
Brian Grey
Ranch Hand

Joined: Nov 15, 2002
Posts: 43
Do you know why I got this output:
<?xml version="1.0" encoding="UTF-8"?>
<XSLTValidationResults version="1.0.0.0" service="CAS" xmlns:ms="urn:schemas-microsoft-com:xslt" xmlns:user="userhtml">
<Test code="CAS_IND_CONTACT_M"><Success/></Test>
<Test code="CAS_IND_NAME_M"><Success/></Test>
<Test code="CAS_IND_DOB_M"><Success/></Test>
</XSLTValidationResults>
for this
<xsl:copy-of select="user:LenderSpecificRules()"/>

function LenderSpecificRules()
Set objXML = CreateObject("MSXML2.DOMDocument.3.0")
Set objXSL = CreateObject("MSXML2.DOMDocument.3.0")

objXML.async = False
objXML.Load ("D:\CAS\DEV\Data\CreditApp_BeforeTransformation.xml")

objXML.save ("D:\CAS\DEV\Data\CAS_Result_LenderSpecificRules_Input.xml")
objXSL.async = False
objXSL.Load ("D:\CAS\DEV\Data\BCEECreditApp_LenderSpecificRules_2.1.5.xsl")

strXMLResult = objXML.transformNode(objXSL)

objXML.LoadXML strXMLResult
objXML.save ("D:\CAS\DEV\Data\CAS_Result_LenderSpecificRules_Output.xml")

LenderSpecificRules= objXML.xml
End function
How can I replace < and > to < and >?
I know that I'm using VBScript. I have no choice.
I prefer working on Java
Brian Grey
Ranch Hand

Joined: Nov 15, 2002
Posts: 43
oops sorry
& lt; and & gt; have been converted automaticaly
How can replace & lt; by <
<?xml version="1.0" encoding="UTF-8"?>
<XSLTValidationResults version="1.0.0.0" service="CAS" xmlns:ms="urn:schemas-microsoft-com:xslt" xmlns:user="userhtml">
& lt;Test code="CAS_IND_CONTACT_M"><Success/& gt;& lt;/Test& gt;
& lt;Test code="CAS_IND_NAME_M"><Success/& gt;& lt;/Test& gt;
& lt;Test code="CAS_IND_DOB_M"><Success/& gt;& lt;/Test& gt;
</XSLTValidationResults>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to save all nodes in a variable
 
Similar Threads
XSL
to EXACT Dublicate an xml file[xml->xml] via Java TransformerFactory classes and XSTL well I do not
Is it Possible in XSL
Transformation Challenge. Transform Tag data into Tag names
creating links in XSL