| sbrady |
| Newbie |
|
| Ireland |
|
|
| None Specified |
|
| Friday, September 11, 2009 |
| Monday, January 11, 2010 5:03:15 PM |
5 [0.03% of all post / 0.00 posts per day] |
|
I have two stylesheets containing different namespaces, using the same include file containing shared functionality. Using saxon I get the following error 'The prefix "n" for element "n:Success" is not bound.'
I don't want to explicitly assign the namespace in the include file, as this needs to change depending on namespace declared in the calling stylesheet, ie. "http://url.com/MyStylesheetOne" or "http://url.com/MyStylesheetTwo".
Is there any way to inherit the namespace from the parent stylesheet?
include.xslt
Code:<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs xsi xsl"> <xsl:template name="Success"> <n:Success/> </xsl:template> </xsl:stylesheet>
StylesheetOne.xslt
Code:<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns="http://url.com/MyStylesheetOne" xmlns:n="http://url.com/MyStylesheetOne" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs xsi xsl"> <xsl:namespace-alias stylesheet-prefix="n" result-prefix="#default"/> <xsl:include href="include.xslt"/> <xsl:output method="xml" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <n:Output1> <xsl:call-template name="Success"/> </n:Output1> </xsl:template> </xsl:stylesheet>
StyleSheetTwo.xslt
Code:<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns="http://url.com/MyStylesheetTwo" xmlns:n="http://www.url.com/MyStylesheetTwo" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs xsi xsl"> <xsl:namespace-alias stylesheet-prefix="n" result-prefix="#default"/> <xsl:include href="include.xslt"/> <xsl:output method="xml" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <n:OutputTwo> <xsl:call-template name="Success"/> </n:OutputTwo> </xsl:template> </xsl:stylesheet>
|
|
Thanks McLine, but I've already tried this approach previously. Due to the size of the xmls we use, we can't afford two transformations due to the processing time.
|
I have a problem with creating unique identifer reference for repeating elements. The problem is when I have repeating elements within repeating elements. For example, if I wanted to get all customers from the following xml and have a sequential refernce value for each.
Code: <?xml version="1.0" encoding="UTF-8"?> <System> <Accounts> <Account> <People> <Person>John Doe</Person> <Person>Jane Doe</Person> <Person>Joe Bloggs</Person> </People> </Account> <Account> <People> <Person>Mary Blogs</Person> <Person>Jim Bob</Person> </People> </Account> </Accounts> </System>
should generate something like this...
Code: <?xml version="1.0" encoding="UTF-8"?> <OutputSystem> <Customers> <Customer Reference="1" Name="John Doe"/> <Customer Reference="2" Name="Jane Doe"/> <Customer Reference="3" Name="Joe Bloggs"/> <Customer Reference="4" Name="Mary Bloggs"/> <Customer Reference="5" Name="Jim Bob"/> </Customers> </OutputSystem>
I have tried to do this using position, but it seems it will only generate this from the closest element parent. John Doe and Mary Bloggs, and Jane Doe and Jim Bob are then given the same references (1, 2).
Is there anyway to generate a counter to do this?
|
The mapforce (2009) manual states file locations can be defined as global resources, however, I can't seem to use global resource reference for Schema files.
For example, I have a global directory resource setup - TestDir pointing to "C:\dev\Altova\Mapforce\MappingDir\Test", I can navigate and add the schema and input xml files using glogal resource view, however, when the component is added the absolute path is added for the schema in the component settings.
Schema file C:\Altova\Mapforce\MappingDir\Test\schema.xsd
Input XML Instance altova://folder_resouce/TestDir/example.xml
How can I use global resource references for Schema files?
|
|