Alternative to using local-name()
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 24
- Joined: Thu Jan 07, 2021 10:44 am
Alternative to using local-name()
Post by DanOvergaard »
Hi
Is there a way to get a value on root level not using "local-name()"? My problem is that my xslt are process by an engine that do not support "local-name()" (Don’t ask me why
)
I have loaded the file into a variable and I need to get the value cbc:ID on root level, but I only figure-out to get it by using:
<xsl:value-of select="$SupplierSeller//*[local-name()='TCOInformationDocument']/cbc:ID"/>
Lording of the file
<xsl:variable name="SupplierSeller" select="document(concat($rootFolder, '\InBound\Input-SupplierSeller.xml'))"/>
XML file
<TCOInformationDocument>
xmlns="urn:oasis:names:specification:ubl:schema:xsd:TCOInformationDocument-2.0.5"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
<cbc:ID>TCO-01</cbc:ID>
<cac:ReferencedContract>
<cbc:ID>1</cbc:ID>
</cac:ReferencedContract>
</TCOInformationDocument>
Any suggestions ?
Regards
Dan
Is there a way to get a value on root level not using "local-name()"? My problem is that my xslt are process by an engine that do not support "local-name()" (Don’t ask me why

I have loaded the file into a variable and I need to get the value cbc:ID on root level, but I only figure-out to get it by using:
<xsl:value-of select="$SupplierSeller//*[local-name()='TCOInformationDocument']/cbc:ID"/>
Lording of the file
<xsl:variable name="SupplierSeller" select="document(concat($rootFolder, '\InBound\Input-SupplierSeller.xml'))"/>
XML file
<TCOInformationDocument>
xmlns="urn:oasis:names:specification:ubl:schema:xsd:TCOInformationDocument-2.0.5"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
<cbc:ID>TCO-01</cbc:ID>
<cac:ReferencedContract>
<cbc:ID>1</cbc:ID>
</cac:ReferencedContract>
</TCOInformationDocument>
Any suggestions ?
Regards
Dan
-
- Posts: 387
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Alternative to using local-name()
Hello Dan,
I think you can replace the "local-name()" with something like this:
I am not sure that this is the best solution, maybe you can address this question on the XSLT List xsl-list@lists.mulberrytech.com.
Best Regards,
Octavian
I think you can replace the "local-name()" with something like this:
Code: Select all
<xsl:value-of select="$SupplierSeller/*/cbc:ID"/>
Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 24
- Joined: Thu Jan 07, 2021 10:44 am
Re: Alternative to using local-name()
Post by DanOvergaard »
Hi Octavian,
Thank for your answer
I had tried <xsl:value-of select="$SupplierSeller/cbc:ID"/> but it didn’t return any value and that was driving me crazy. So, I used local-Name() – go a value, but then the post-process failed (Sorry for not being 100% clear in the problem description)
I figured-out that the problem was due to a “unprefixed name” (Root element: TCOInformationDocument). XPath treat an unprefixed name as a “no namespace” and in the document it’s linked to the default namespace which had no prefix.
I am not still 100% sure if I had understood the problem 100%, but I got the to work by:
adding the following namespace
Xmlns:default="urn:oasis:names:specification:ubl:schema:xsd:TCOInformationDocument-2.0.5"
Change the variable to load the “default:TCOInformationDocument”
<xsl:variable name="SellerSupplier" select="document('\InBound\TCOInformationDocument-Input-SellerSupplier.xml')/default:TCOInformationDocument"/>
Now the <xsl:value-of select="$SupplierSeller/cbc:ID"/> was working
Thanks for your help - with your suggestion, I realize that the problem was not the “select” and the solution must be somewhere else
Regards,
Dan
Thank for your answer
I had tried <xsl:value-of select="$SupplierSeller/cbc:ID"/> but it didn’t return any value and that was driving me crazy. So, I used local-Name() – go a value, but then the post-process failed (Sorry for not being 100% clear in the problem description)
I figured-out that the problem was due to a “unprefixed name” (Root element: TCOInformationDocument). XPath treat an unprefixed name as a “no namespace” and in the document it’s linked to the default namespace which had no prefix.
I am not still 100% sure if I had understood the problem 100%, but I got the to work by:
adding the following namespace
Xmlns:default="urn:oasis:names:specification:ubl:schema:xsd:TCOInformationDocument-2.0.5"
Change the variable to load the “default:TCOInformationDocument”
<xsl:variable name="SellerSupplier" select="document('\InBound\TCOInformationDocument-Input-SellerSupplier.xml')/default:TCOInformationDocument"/>
Now the <xsl:value-of select="$SupplierSeller/cbc:ID"/> was working
Thanks for your help - with your suggestion, I realize that the problem was not the “select” and the solution must be somewhere else
Regards,
Dan
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service