IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Profile: hfeldma1
About
User Name: hfeldma1
Forum Rank: Newbie
Real Name:
Location Canada
Occupation:
Interests:
Gender: None Specified
Statistics
Joined: Friday, September 2, 2016
Last Visit: Friday, September 23, 2016 6:14:57 PM
Number of Posts: 4
[0.02% of all post / 0.00 posts per day]
Avatar
Last 10 Posts
Topic: XSLT lookup using regex
Posted: Friday, September 23, 2016 6:14:57 PM
Thank you so much, works like a charm.
Topic: Datatype mismatch
Posted: Friday, September 23, 2016 1:13:48 AM
I have the following set of variables
Code:
    <xsl:variable name="LookupLTE" select="document('HuaweiLTE.xml')/Huawei"/>
    <xsl:variable name="LookupHSPA" select="document('HuaweiHSPA.xml')/Huawei"/>
    <xsl:variable name="LookupDoc" select="if (substring($DeviceName,1,1)='L') then $LookupLTE else if (substring($DeviceName,1,1)='H') then $LookupHSPA else ()"/>


I get an XPTY0004 error of for the following
Code:
<xsl:value-of select="key('table-lookup', $curr_key, $LookupDoc)/@ColumnName"/>


And yet the following works just fine?
Code:
<xsl:value-of select="key('table-lookup', $curr_key, $LookupLTE)/@ColumnName"/>
Topic: XSLT lookup using regex
Posted: Wednesday, September 21, 2016 8:51:46 PM
Good point, so a sample input (i.e. $curr_key) to the document lookup would be
Code:
LTHAB0113422/Cell:eNodeB Function Name=LTHAB0113422, Local Cell ID=0, Cell Name=LTHAB0113422-000-2100-1-1, eNodeB ID=113422, Cell FDD TDD indication=CELL_FDD/CnOperator:CnOperatorId=0


This should match with the first element (Key1) in the sample document posted. Does XSLT 3.0 maybe support this?
Topic: XSLT lookup using regex
Posted: Wednesday, September 21, 2016 1:15:17 PM
I'm familiar with using lookup document in XSLT, however I'm hoping it's possible to do the lookup using regex? I've attached a sample from the lookup document:
Code:
<Telsa xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <Row Key1="^[A-Z0-9]+/Cell:eNodeB Function Name=[A-Z0-9]+, Local Cell ID=[0-9]+, Cell Name=.*/CnOperator:CnOperatorId=[0-9]+$" ElementType="CELL_CORE_OPERATOR" RegexReplace="&apos;^([A-Z0-9]+)/Cell:eNodeB Function Name=[A-Z0-9]+, Local Cell ID=([0-9]+), Cell Name=.*/CnOperator:(CnOperatorId=[0-9]+)&apos;, &apos;$1/CELL:$2/$3&apos;"></Row>
  <Row Key1="^\w+-\w+-\w+-\d+/Cell:eNodeB Function Name=[A-Z0-9]+, Local Cell ID=[0-9]+, Cell Name=.*, eNodeB ID=[0-9]+, Cell.*$" ElementType="CELL" RegexReplace="&apos;^\w+-\w+-\w+-\d+/Cell:eNodeB Function Name=([A-Z0-9]+), Local Cell ID=([0-9]+), Cell Name=.*, eNodeB ID=([0-9]+), Cell.*$&apos;, &apos;$1/Cell:$2&apos;"></Row>
  <Row Key1="^\w+-\w+-\w+-\d+/EthernetInterface:Ethernet Interface No.=.*$" ElementType="EthernetInterface" RegexReplace="&apos;^(\w+-\w+-\w+-\d+)/EthernetInterface:Ethernet Interface No.=([0-9]+)$&apos; , &apos;$1/No=$2&apos;"></Row>
  <Row Key1="^[A-Z0-9]+/CELL:Local cell identity=[0-9]+, Cell Name=.*/OPERATOR:CnOperatorId=[0-9]+$" ElementType="CELL_CORE_OPERATOR" RegexReplace="&apos;^([A-Z0-9]+/CELL:)Local cell identity=([0-9]+), Cell Name=.*/OPERATOR:(CnOperatorId=[0-9]+)&apos; , &apos;$1$2/$3&apos;"></Row>
  <Row Key1="^[A-Z0-9]+/Cell:Local cell identity=[0-9]+, Cell Name=.*, eNodeB identity=[0-9]+$" ElementType="CELL" RegexReplace="&apos;^([A-Z0-9]+/Cell:)Local cell identity=([0-9]+), Cell Name=.*, eNodeB identity=[0-9]+$&apos;, &apos;$1$2&apos;"></Row>
  <Row Key1="^[A-Z0-9]+/Cell:eNodeB Function Name=[A-Z0-9]+, Local Cell ID=[0-9]+, Cell Name=.*, eNodeB ID=[0-9]+$" ElementType="CELL" RegexReplace="&apos;^([A-Z0-9]+)/Cell:eNodeB Function Name=[A-Z0-9]+, Local Cell ID=([0-9]+), Cell Name=.*, eNodeB ID=([0-9]+)$&apos;, &apos;$1/Cell:$2&apos;"></Row>
  <Row Key1="^[A-Z0-9]+/Cell:eNodeB Function Name=[A-Z0-9]+, Local Cell ID=[0-9]+, Cell Name=.*, eNodeB ID=[0-9]+$" ElementType="CELL" RegexReplace="&apos;^([A-Z0-9]+)/Cell:eNodeB Function Name=[A-Z0-9]+, Local Cell ID=([0-9]+), Cell Name=.*, eNodeB ID=([0-9]+)$&apos;, &apos;$1/Cell:$2&apos;"></Row>
</Telsa>


This is what I have defined in the XSLT for the lookup:
Code:
<xsl:key name="table-lookup" match="Row" use="@Key1"/>
<xsl:variable name="LookupDoc" select="document('Telsa.xml')/Telsa"/>


So my thinking is I need to change the following somehow, question is to what:
Code:
<xsl:value-of select="key('table-lookup', $curr_key, $LookupDoc)/@ElementType"/>

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.