Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Namespace problem (Stylesheet)

Status
Not open for further replies.

adam05

Programmer
Joined
Apr 24, 2005
Messages
3
Location
AU
Hi All,

I am trying to create Stylesheet to transform data from an ERP system to a format Microsoft Access can import. Mind you I am a novice when it comes to XML so my question maybe very basic.
I am having problems referencing nodes as they have prefixed with "aso" as follows;

<aso:Message xmlns=" xmlns:aso="
<aso:TasksForScheduling>
<aso:Task>
<TaskName>Design Offline</TaskName>
.....
</TaskName>
</aso:TasksForScheduling>
</aso:Message>

Part of my code in the stylesheet won't work(can't reference node move through each;

<xsl:for-each select ="/Message/TasksForScheduling/Task">
...
...
</xsl:for-each>

Any help would be appreciated,

Cheers,
Adam.
 
You will need to add the namespaces to the stylesheet. Also, because you are using a default namespace, you will need to give that an arbitary prefix too:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] xmlns:tttv="[URL unfurl="true"]http://www.tttv1.0"[/URL] xmlns:aso="[URL unfurl="true"]http://www.bbb">[/URL]
Now in your XPath put the prefixes on. Wherever you use a node in the default namespace you will have to use the arbitary prefix, eg to select Task you would use:
Code:
aso:Message/aso:TasksForScheduling/aso:Task
To select TaskName you would use:
Code:
aso:Message/aso:TasksForScheduling/aso:Task/tttv:TaskName

Jon

"I don't regret this, but I both rue and lament it.
 
Thanks JontyMC for replying, everything works well now with the inclusion of the namespaces.

Thanks again.

Adam.
 
adam05

it's always worth checking out the FAQ's first.

faq426-1188
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top