XML

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentXML

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old August 4th, 2011, 11:18 AM
abnerliu abnerliu is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 2 abnerliu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 58 sec
Reputation Power: 0
Transform self-define namespace XML with DOM, can't make value in the result Document

Hi All
I have an issue when using DOM to transform an XML with name space. I create an XSL to transform the XML, but when I using DOM to transform it, I found the result document has no value.
the sample XML I used as below:
<?xml version="1.0" encoding="UTF-8"?>
<aa:root xmlns:aa="a url here, but can't display here">
<aa:people>
<aa:name>apple</aa:name>
<aa:sex>male</aa:sex>
</aa:people>
</aa:root>

the XSL I created as below:
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="(a url here, but can't display here)" version="1.0"
xmlns:aa="(a url here, but can't display here)">

<xsl:template match="/">
<root>
<xsl:call-template name="test"/>
</root>
</xsl:template>

<xsl:template name="test">
<hh>
<xsl:value-of select="/aa:root/aa:people/aa:sex/text()"/>
</hh>
</xsl:template>

</xsl:stylesheet>

and Java DOM codes I came up with as below:
public void transformWithDOM() throws Exception{
TransformerFactory factory = TransformerFactory.newInstance();
Templates translet = factory.newTemplates(new StreamSource(xslFile));

DOMSource source = null;
Transformer transformer = null;
DOMResult resultXmlDoc = null;

Document srcXmlDoc = getDocObj(strxml);

source = new DOMSource(srcXmlDoc);
resultXmlDoc = new DOMResult();
transformer = translet.newTransformer();
transformer.transform(source, resultXmlDoc);

Document outputDoc = (Document) resultXmlDoc.getNode();
}

the expected result should be:
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:aa="(a url here, but can't display here)">
<hh>male</hh>
</root>

but, actually the result is:
<root xmlns:aa="(a url here, but can't display here)">
<hh/>
</root>

can any one help to indicate, how should I do, can get the expected result?

Reply With Quote
  #2  
Old August 4th, 2011, 11:21 AM
abnerliu abnerliu is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 2 abnerliu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 58 sec
Reputation Power: 0
Unhappy

the name space I defined in the xml and xslt is unique, but because of this forum not allow me to input url due to I am new user, so can't display it..

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentXML > Transform self-define namespace XML with DOM, can't make value in the result Document


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap